安装nuget软件包后编辑projectFile.csproj

时间:2019-11-14 12:57:26

标签: c# nuget nuget-package nuget-spec

我正在为nuget创建一个软件包,我想编辑project.csproj文件并在软件包安装过程中替换一些代码。

可以使用nuspec文件吗?

还是应该使用PowerShell脚本?如有可能,请使用PowerShell举个例子

1 个答案:

答案 0 :(得分:1)

您正在寻找MSBuild props/targets extensibility

无论您要对放置在props或target文件中的项目文件进行什么更改(props都会在评估csproj之前导入,然后是target)。您需要使用正确的命名约定,但是如果使用不正确,NuGet 5.3(如果使用dotnet pack,则包含在.NET Core SDK 3.0中)现在会发出警告。然后,当项目使用您的软件包时,NuGet告诉构建系统的其余部分导入您的软件包props / targets文件。