我的项目有
<ItemGroup>
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="FSharp.Core" Version="4.5.4" />
</ItemGroup>但是当我运行nuget restore (在TeamCity中,或者从TeamCity服务器上的命令行)时,它会还原FSharp.Core的最新版本(目前是4.7),而不是所需的版本。
C:\Users\Benjol>C:\TeamCity\buildAgent\tools\NuGet.CommandLine.4.3.0\tools\NuGet.exe restore C:\TeamCity\buildAgent\work\8e6167a865903fc4\Components\Externals\Company.LabVIEW\Company.LabVIEW\Company.LabVIEW.fsproj
MSBuild auto-detection: using msbuild version '16.3.0.46305' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\bin'.
Restoring packages for C:\TeamCity\buildAgent\work\8e6167a865903fc4\Components\Externals\Company.LabVIEW\Company.LabVIEW\Company.LabVIEW.fsproj...
GET https://api.nuget.org/v3-flatcontainer/fsharp.core/index.json
OK https://api.nuget.org/v3-flatcontainer/fsharp.core/index.json 458ms
GET https://api.nuget.org/v3-flatcontainer/fsharp.core/4.7.0/fsharp.core.4.7.0.nupkg
OK https://api.nuget.org/v3-flatcontainer/fsharp.core/4.7.0/fsharp.core.4.7.0.nupkg 16ms
Installing FSharp.Core 4.7.0.
Committing restore...
Generating MSBuild file C:\TeamCity\buildAgent\work\8e6167a865903fc4\Components\Externals\Company.LabVIEW\Company.LabVIEW\obj\Company.LabVIEW.fsproj.nuget.g.props.
Writing lock file to disk. Path: C:\TeamCity\buildAgent\work\8e6167a865903fc4\Components\Externals\Company.LabVIEW\Company.LabVIEW\obj\project.assets.json
Restore completed in 2.13 sec for C:\TeamCity\buildAgent\work\8e6167a865903fc4\Components\Externals\Company.LabVIEW\Company.LabVIEW\Company.LabVIEW.fsproj.
NuGet Config files used:
C:\Users\Benjol\AppData\Roaming\NuGet\NuGet.Config
Feeds used:
https://api.nuget.org/v3/index.json
Installed:
1 package(s) to C:\TeamCity\buildAgent\work\8e6167a865903fc4\Components\Externals\Company.LabVIEW\Company.LabVIEW\Company.LabVIEW.fsproj有什么建议吗?或者我可以进一步研究的方法?
发布于 2019-09-25 16:14:03
你可以看看nuget lock file
发布于 2019-09-25 16:17:15
您是否在"NuGet Installer“构建步骤中启用了"Update packages version”选项?

发布于 2019-09-25 17:47:53
这很奇怪。根据@Bohdan's的建议,我研究了使用锁定文件的可能性,但显然nuget.exe中没有命令行参数才能使用它,您必须转向dotnet.exe或使用msbuild恢复目标。
但经过一些实验,似乎如果我使用msbuild,它无论如何都会恢复所需的/正确的版本,所以我根本不需要锁文件。
但是,packages.config restore只处理PackageReference,而且我还有一些使用msbuild的旧项目。因此,这意味着我必须首先执行nuget恢复(它恢复packages.config,但获得错误的FSharp版本),然后使用msbuild restore (它会更正为正确的FSharp版本-我想!)。
我很高兴我通过这类工作获得了报酬,但这并没有提高我的生产力!
这是使用msbuild工具2017,刚刚升级到2019,现在msbuild正在做与nuget相同的事情:(
https://stackoverflow.com/questions/58093067
复制相似问题