Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dll as a refrence , Copy local to false, does not have entry in deps.json #2162

Closed
ankgupta067 opened this issue Apr 19, 2018 · 17 comments
Closed
Milestone

Comments

@ankgupta067
Copy link

create a .net standard dll , name it as Paas dll, and change the output path ..\Output\

add a class logger like below-

public class Logger 
    {
        public void LogMessage()
        {
            Console.Write("test");
        }
    }

Now create another .net core console project in solution and add dll as a refrence ( not project refrence) for pass.dll and make copy local to false.

Also change output directory of console app to ..\Output\

add below code in console app -

var logger = new Logger();
 logger.LogMessage();
 Console.Read();

Build and run .net core app, but now application goes in break mode with below error

Could not load file or assembly 'Paas, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

On further investigation i see that refrence to .net standard dll in deps.json is missing and it is according to the code here

Is it by design or this is a bug , if by design how to fix this?

@livarcocc livarcocc added this to the 2.2.1xx milestone Apr 19, 2018
@tannergooding
Copy link
Member

This is "by design". CopyLocal is used to differentiate between compile time and runtime references.

It may be possible to add some new metadata (e.g. AddReferenceToDepsJson, IsRuntimeReference, etc) that allows tracking. However, it may also be desirable to specify that the current/specified directory should also be searched.

CC. @eerhardt, @livarcocc

@eerhardt
Copy link
Member

@steveharter - here is another case where the right assembly is sitting in the 'bin' directory where the executable is running out of, but the runtime refuses to load it because it isn't in the .deps.json file.

You and I have discussed before potentially allowing for this scenario, where an assembly can still be loaded even though it wasn't in the .deps.json file. What do you think here?

@steveharter
Copy link
Member

Pending security review, yes IMO we should automatically support every local assembly by default.

@steveharter
Copy link
Member

Note we will automatically pull in assemblies if there is no deps.json file, so I think by also pulling in local assemblies when we have a deps already makes us more consistent and provides a path to have a minimal deps.json file.

@borgdylan
Copy link

I am having a similar issue but I am marking both CopyLocal and Private to true. The referenced library does get copied to bin folder, but for the CLR to load it I have to resort to manually hacking the deps.json file. Can these be added automatically if CopyLocal is marked to true or is there some piece of metadata that I can set to force this?

@eerhardt
Copy link
Member

@borgdylan - if you are using a 2.0+ .NET Core SDK, your scenario should just work. Can you send the .csproj? Also, building with dotnet build /bl and attaching the output .binlog file helps to diagnose these issues.

@borgdylan
Copy link

I am using a custom compiler so my project file has a different extension but is in the same format. Also I am using the SDK used by the mono fork of MSBuild, not the actual .NET Core SDK.

@borgdylan
Copy link

borgdylan commented May 29, 2018

I discovered that the dll is included in the deps.json for the directly referencing project, and not in the project for the console app that uses the other library as a project reference.

@borgdylan
Copy link

@eerhardt Where should I send the files?

@eerhardt
Copy link
Member

If they are not too large, you can attach them in GitHub. Or using dropbox or a similar service.

However, reading

I discovered that the dll is included in the deps.json for the directly referencing project, and not in the project for the console app that uses the other library as a project reference.

It sounds like you will need to add the .dll as a <Reference> to the console app project as well. This was issue #1609, which we've fixed in the .NET Core 2.1.300 SDK, which will be shipping soon.

@borgdylan
Copy link

https://1drv.ms/u/s!AiEyErw26P-fiUiUiGLyh-mY4Uwh

That is is a zip file with the binlog file as well as two projects, one references teh dll directly and thr other references the latter among other projects. If you need to look at other files, I will be happy to send them.

@borgdylan
Copy link

borgdylan commented May 29, 2018

Weird thing, when referencing in the console project MSBuild is not passing it in to the compiler when building said project. My custom language happens to take references as code (generated using an MSBuild task) and the reference for the particular dll is in the projects thata ctually need it but not in the console app (completely ignoring the fact the dll is still refernced)

@borgdylan
Copy link

borgdylan commented May 29, 2018

Disregard the last comment, it was my mistake. The console app uses netcoreapp2.0, but the class libraries netstandard2.0. I had copied the reference verbatim without changing the condition on the references.

@borgdylan
Copy link

After that change, I managed to run without modification of deps.json using both the shared framework (dotnet command) as well as from a self-contained published directory. Thanks for all your help @eerhardt, your idea made it work! That's another compiler runnign on .NET Core.

@ankgupta067
Copy link
Author

@livarcocc is there a commit to address this issue , if not how is it fixed / closed ?

@ankgupta067
Copy link
Author

@eerhardt is this issue fixed?

@steveharter
Copy link
Member

@ankgupta067 based on #1609 this PR was merged on April 10th: #2090

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants