Reputation: 66541
My project has
<ItemGroup>
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="FSharp.Core" Version="4.5.4" />
</ItemGroup>
But when I run a nuget restore (in TeamCity, or from the command line on the TeamCity server), it restores the latest version of FSharp.Core (4.7 at present) instead of the required version.
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
Any tips? Or ways I can research further?
Upvotes: 0
Views: 573
Reputation: 66541
This is weird. Following @Bohdan's suggestion, I looked into the possibility of using a lock file, but apparently there is no command line parameter in nuget.exe to be able to use it, you have to turn to dotnet.exe or use the msbuild restore target.
But having experimented a bit, it seems that if I use msbuild, it restores the desired/correct version anyway, so I don't need the lock file after all.
But, msbuild restore only handles PackageReference, and I've got a few older projects which are using packages.config. So this means I have to do nuget restore first (which restores packages.config, but gets the wrong version of FSharp), and then follow it with msbuild restore (which corrects to the right version of FSharp - I think!).
I'm glad I get paid to work through this kind of thing, but it's not increasing my productivity!
This was using msbuild tools 2017, just upgraded to 2019 and now msbuild is doing the same thing as nuget :(
Upvotes: 0
Reputation: 349
Did you enable the "Update packages version" option in "NuGet Installer" build step?
Upvotes: 1