I have some requirement to set Copy Local to false for the NuGet dll. Before that, I used the package.config format and everything worked fine. After migration to Package Reference format, I cannot find a way how to do that. Could someone help me?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
You can use PrivateAssets. Copied from the docs
edit: actually, you might need to use
<ExcludeAssets>runtime</ExcludeAssets>
.The easiest way would be to right click the dll and select properties from the solution explorer view under the references tab. From there you can set the flag manually for the whole package.
If that doesn't work in your case, then you might be able to set the Copy Local flag in the package.config format as you had been doing and then migrate that dependency into your project as Package Reference format.
I wrote this msbuild target to hack
<packagereference ..><privateassets>all</privateassets>...
or<privateassets>runtime;...
to act like the old<reference><private>true</private>...
(copy local property on ref set to false).Import the below target in your .csproj file or a Directory.Build.targets file in the solution root.
I am sure the itemgroup merging can be optimized somehow. Hope it helps, feedback is welcome.