I have a project using a custom nuget package.
The nuget package uses some dlls, added to the project with property "Copy to output directory" set to "Copy always".
When I install the nuget package in the main project the dlls are added to it, but property "Copy to output directory" is set to "Do not copy".
Consequently, when I publish my project, necessary files are missing.
Is there a way to maintain the value of the property "Copy to output directory" of files copied from a nuget package?
To solve this, I have to manually set the property "Copy to output directory" to "Copy always" each time I install my nuget package or I clone the main project from the GIT repository.
Attached are some screenshots illustrating my settings. I also added the
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
option to the csproj of the main project, that uses the nuget package. But it doesn't work. The dll is still missing in the publish folder.
You can set CopyLocalLockFileAssemblies
to true
in your .csproj
file as shown below. This will cause the build service to always include dependencies in your build output.
<PropertyGroup>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
For more information see the entry in the list of MSBuild properties in the Microsoft docs:
The CopyLocalLockFileAssemblies property is useful for plugin projects that have dependencies on other libraries. If you set this property to true, any transitive NuGet package dependencies are copied to the output directory. That means you can use the output of dotnet build to run your plugin on any machine.