[英]How can I manipulate the Packageversion on a multi target project when manipulation comes from a NuGet package
I have a NuGet package with a targets file which manipulates the PackageVersion depending on the current context (When the branch is master it's creates a preview).我有一个 NuGet package 和一个目标文件,它根据当前上下文操作 PackageVersion(当分支是主分支时,它会创建一个预览)。
This is working well on a normal project but when I use this in a multi target project it's not working.这在普通项目上运行良好,但当我在多目标项目中使用它时,它不起作用。
How can I correct this?我该如何纠正这个问题?
I have attached a sample project.我附上了一个示例项目。 https://1drv.ms/u/s?At1IZ7t_aXW-iNRchOhliGP8dunGHg?e=11dW4F To reproduce the problem: https://1drv.ms/u/s?At1IZ7t_aXW-iNRchOhliGP8dunGHg?e=11dW4F要重现问题:
This creates a package of consumer with version 1.0.0.这将创建一个 package 版本为 1.0.0 的消费者。 This should bie 1.0.0-xdev.这应该是 1.0.0-xdev。
When you change Consumer.csproj so that TargetFramework is used the correct version is created当您更改 Consumer.csproj 以便使用 TargetFramework 时,会创建正确的版本
I have tried the version modification outside of the target but this leads to problems when the version number is specified in a Directory.Build.Targets file我尝试了目标之外的版本修改,但是当在 Directory.Build.Targets 文件中指定版本号时,这会导致问题
I have tried different BeforeTargets in but nothing worked.我尝试了不同的 BeforeTargets 但没有任何效果。
When you use multi-targetframeworks property like <TargetFrameworks.net461</TargetFrameworks>
, build
folder of the nuget package cannot act well and it cannot service for multi-target frameworks, only for single taget framework.当您使用像<TargetFrameworks.net461</TargetFrameworks>
这样的多目标框架属性时, nuget package 的build
文件夹不能正常运行,它不能为多目标框架服务,只能为单目标框架服务。
Instead , you should abandon build
and use buildCrossTargeting
.相反,您应该放弃build
并使用buildCrossTargeting
。
Under BuildConfig
project, if it is a new sdk project, please use this BuildConfig
工程下,如果是新建sdk工程,请使用这个
<ItemGroup>
<None Include="BuildConfig.targets" Pack="true" PackagePath="buildCrossTargeting" />"
</ItemGroup>
If you use nuspec file, you should use this undr the file:如果你使用nuspec文件,你应该在文件下使用这个:
<file src="BuildConfig.targets" target="buildCrossTargeting/" />
You should note that the xxx.targets
files should be under buildCrossTargeting
folder directly without any sub folders, otherwise, it will not work.请注意, xxx.targets
文件应直接位于buildCrossTargeting
文件夹下,没有任何子文件夹,否则将无法运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.