@nefcanto commented on Sat Dec 23 2017
Referenced assemblies which are set to Copy Local are not copied to the output directory
I've described this in this StackOverflow question too.
I want to work with Azure Storage. I've added Nuget package references, this way:
<ItemGroup>
<PackageReference Include="WindowsAzure.Storage" Version="8.7.0" />
<PackageReference Include="Microsoft.WindowsAzure.ConfigurationManager" Version="3.2.3" />
</ItemGroup>
However, when I build the project (which is a web project by the way), I receive an error that it can't find the required DLL files from these packages. When I look at the output folder which is bin\Debug\netcoreapp2.0\ in my case, I see that no DLL from those packages exist in that folder.
The point that it can't find those DLL files means that something is not working properly. We expect by including a package reference in CSPROJ, all of the required actions be taken care of automatically.
So, I decided to add extra lines of code, to explicitly copy the required DLL files to the output folder:
<ItemGroup>
<Reference Include="Microsoft.WindowsAzure.Configuration">
<HintPath>..\Microsoft.WindowsAzure.Configuration.dll</HintPath>
<Private>true</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Storage">
<HintPath>..\Microsoft.WindowsAzure.Storage.dll</HintPath>
<Private>true</Private>
</Reference>
</ItemGroup>
But they are not getting copied. What's the problem?
@Petermarcu commented on Sat Dec 23 2017
I think you need to go back to package references and you need to do dotnet publish to produce a build of your application with everything copied. dotnet build and dotnet run do things the "fast way" which is to reference things where they are on disk and avoid the cost of copying to the app folder. Publish is the way to build your final application with everything copied local. Make sure you run your app from the publish folder at that point using dotnet path/to/publish/folder/App.dll.
@brentmorrisa commented on Fri Feb 09 2018
Dotnet publish is not getting my copy-local true files, either.
@nefcanto can you share a small repo repro of your issue?
I realized that this error is a bug, and thus kept updating VS as new updates arrived, and now I don't have it anymore. I'm using VS 2017 Community Edition Update 15.6.2.
Ok, given that, I am going to close this issue. If this you hit this again, just comment and we can re-activate.
I met the same issue on VS 2017 Enterprise 15.8.4. Anyone know if there has been a fix for it?
I am facing this issue with .Net Core 2.2, VS Code, Ubuntu 18.04 LTS. Is there any way I can fix it.
@nikunjratanpara assets from package references are only copied when running dotnet publish for .NET Core 2.x. In 3.0, we now copy package assets on build too.
Are you running the output from dotnet build or dotnet publish?
If you create a new .net core wpf project and add a com dependency the related dll will also not copied on publishing to the output directory.
Most helpful comment
I met the same issue on VS 2017 Enterprise 15.8.4. Anyone know if there has been a fix for it?