[英]How to remove the dependencies section from nuspec file in the generated nuget package using msbuild 15
I use msbuild v15.8.168.64424 (vs 2017.8) commandline to build nuget package for console application. 我使用msbuild v15.8.168.64424(vs 2017.8)命令行为控制台应用程序构建nuget软件包。 I used ILMerge to merge all dependencies, so I get only one exe file without dependencies.
我使用ILMerge合并所有依赖项,因此我只得到一个没有依赖项的exe文件。
When runing the command 运行命令时
msbuild project1.csproj /t:build /p:configuration=release /p:IsTool=true
I get the nuget package, but when inspecting it, I find the dependencies section
. 我得到了nuget包,但是在检查它时,我发现了
dependencies section
。
<dependencies>
<group targetFramework=".NETFramework4.5">
<dependency id="lib1" version="1.3.0" exclude="Build,Analyzers" />
<dependency id="lib2" version="2.3.0" exclude="Build,Analyzers" />
</group>
</dependencies>
I want the `dependencies section to be empty (because I merged all the dependencies). 我希望`dependencies'部分为空(因为我合并了所有依赖项)。
I can use nuspec file to generate the package without dependencies section, but the drawback is passing manually all the metadata which is included in csproj. 我可以使用nuspec文件来生成无依赖项部分的程序包,但是缺点是手动传递了csproj中包含的所有元数据。 I didn't find a property for the dependencies in pack target inputs
我没有在包目标输入中找到依赖项的属性
The Question: 问题:
How I remove the dependencies section from the nuspec file which is included in the generated nuget package? 如何从生成的nuget包中包含的nuspec文件中删除依赖项部分?
You can set the metadata PrivateAssets="All"
on the package or project references ( <PackageReference>
/ <ProjectReference>
) in the csproj file to exclude them as NuGet dependencies. 您可以在csproj文件中的程序包或项目引用(
<PackageReference>
/ <ProjectReference>
)上设置元数据PrivateAssets="All"
,以将它们排除为NuGet依赖项。
Note that this change needs a restore so perform a NuGet restore in between or add -restore
to the MSBuild invocation. 请注意,此更改需要还原,因此请在两者之间执行NuGet还原或将
-restore
添加到MSBuild调用中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.