问题描述
此问题特定于 MSBuild 15.1+ (Visual Studio 2017) 和 PackageReference,这是完全集成 Nuget
的新方式在 MSBuild
中.
This question is specific to MSBuild 15.1+ (Visual Studio 2017) and to PackageReference, which is the new way Nuget
is fully integrated within MSBuild
.
在我的持续集成脚本中,我有类似的东西:
In my continuous integration script, I've got something like:
MSBuild.exe /t:Restore MySolution.sln /p:RestoreConfigFile=NuGet.config
其中一个 csproj
文件包含:
One of the csproj
file contains:
<PackageReference Include="MyPackageA">
<Version>1.2.*</Version>
</PackageReference>
MyPackageA
是一个内部包,我希望 nuget 解析对可用最新版本的引用,包括预发布版本.
MyPackageA
is an internal package and I would like nuget to resolve the reference to the latest version available, including pre-release version.
举两个例子:
示例 #1
可用的包有:
- MyPackageA 版本 1.2.7-dev1
- MyPackageA 版本 1.2.7-dev2
- MyPackageA 版本 1.2.7-dev3
- MyPackageA 版本 1.2.8
我希望 nuget 解决依赖关系并选择 MyPackageA 版本 1.2.8.
I would like nuget to resolve the dependency and pick up MyPackageA version 1.2.8.
示例 #2
可用的包有:
- MyPackageA 版本 1.2.7-dev1
- MyPackageA 版本 1.2.7-dev2
- MyPackageA 版本 1.2.7-dev3
- MyPackageA 版本 1.2.8
- MyPackageA 版本 1.2.9-dev1
- MyPackageA 版本 1.2.9-dev2
我希望 nuget 解决依赖关系并选择 MyPackageA 版本 1.2.9-dev2.
I would like nuget to resolve the dependency and pick up MyPackageA version 1.2.9-dev2.
但是,在两个示例中,它只会解析为 1.2.8 版(稳定版本).
However, it would only resolve to version 1.2.8 (the stable release) in both examples.
有没有办法告诉 MSBuild
或 Nuget
包含预发布包?
Is there a way to tell MSBuild
or Nuget
to include pre-release packages?
推荐答案
目前,预发布版本不能与浮动版本一起使用.
At the moment, prerelease versions cannot be used together with floating versions.
你可以使用
<PackageReference Include="mypk" Version="1.0.*" />
或
<PackageReference Include="mypk" Version="1.0.1-*" />
但不是1.0.*-*
.
请参阅此 GitHub 问题,其中跟踪此功能请求.
See this GitHub issue where this feature request is tracked.
这篇关于如何在 MSBuild 还原目标中包含预发布包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!