MSBuild Step does not respect "/restore" or "/r" argument for nuget restore
With the latest versions of MSBuild finally making it into professional development environments, we have made the switch to use "Package Reference" nuget packages rather than the old "packages.config" way. "Package Reference" adds the nuget reference directly to the .csproj file and is definitely the preferred way to cache nuget packages on the system.
When the "/restore" argument is supplied to the MSBuild step, the build does not restore. The only way I have gotten the build step to restore is by providing a Target as "Restore;Build" in order to get the packages to restore. Now this works in most cases, but sometimes it causes unforeseen problems with vc++ projects when the "restore" target is provided.
I know the build tools support the /restore option because I can run them from command prompt on the agent and it does indeed restore. It looks like it may be a bug in the MSBuildBootstrap not passing the arguments. In fact, it makes me wonder if any of the arguments like /m actually work when supplied.
If anyone has experienced this problem, any help would be much appreciated!
Please sign in to leave a comment.
Please use the .NET runner with msbuild command instead MSBuild or Visual Studio (sln) runners.
Hi Tanner,
as far as I can tell, the passed parameters do work. Which version of MSBuild are you trying to use? Which version of TeamCity are you running?
Are you using only the MSBuild runner or are you using the NuGet Installer? https://confluence.jetbrains.com/display/TCD10/NuGet+Installer
Denis, I am currently running 2017.2.1. I will update in the morning to see if it fixes the issue.
How can I enable logging in order to verify the arguments are being passed in correctly? My build step looks like the following:
msBuild {
name = "Build Step Name"
id = "uniqueId"
path = "path/to/my/solution.sln"
version = MSBuildStep.MSBuildVersion.15_0
toolsVersion = MSBuildStep.MSBuildToolsVersion.V15_0
targets = %system.Targets% (Targets = Build)
args = "/r /m"
}
Denis,
I have updated the server to 2017.2.2 and I still have the same affliction. See the attached build log, and you can clearly see the above step is certainly not restoring.
Step 3/54: Build Support (MSBuild) (59s)
[15:13:36][Step 3/54] Starting: C:\TeamCity\BuildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.MsBuildBootstrap.exe /workdir:C:\TeamCity\BuildAgent3\work\2d7b3aab65538de7"/msbuildPath:C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\bin\MSBuild.exe"
[15:13:36][Step 3/54] in directory: C:\TeamCity\BuildAgent3\work\2d7b3aab65538de7
[15:13:40][Step 3/54] Support.sln.teamcity: Build target: TeamCity_Generated_Build (37s)
[15:13:40][Support.sln.teamcity] TeamCity_Generated_Build (37s)
[15:13:40][TeamCity_Generated_Build] MSBuild (37s)
[15:13:41][MSBuild] Support.sln: Build target: Build (36s)
[15:13:41][Support.sln] ValidateSolutionConfiguration
[15:13:41][Support.sln] Build (36s)
[15:13:41][Build] MSBuild (36s)
Please advise.
This is still very much a problem for us. Is there anyone that has experienced this issue? We could really use some help here.
Edit: I've confirmed the args section does work, but the /restore is not working.
MSBuild `/restore` option is available in NuGet 4 and MSBuild 15.5 (VS 2017 with latest updates). The `restore` option only works for projects using the new "PackageReference" project style and it does not work for projects using packages.config. Make sure that your projects meet these requirements.
Also try running build from the command line with `/restore` to make sure that your solution can be build successfully.
I have run the '/restore' option from command line for one of my solutions in the command line runner for some time now because I do not want some build properties passed into that particular solution. It builds fine with the `/restore' option but the msbuild steps do not. I have also confirmed they are both executing the same msbuild.exe
Have you been able to successfully use '/restore'?
Did anyone get this working yet?
Can confirm that we have the same bug:
2018.1.3 (build 58658) does not respect /restore, however for instance /p:SomeVariable=blah works if I change the last line.
msBuild {
name = "Build"
path = "MySoftware.sln"
toolsVersion = MSBuildStep.MSBuildToolsVersion.V15_0
platform = MSBuildStep.Platform.x64
args = "/restore"
}
I have this problem too. It's like the /r flag just doesn't get passed through to msbuild.
I have the same problem too. Any updates on this or any workarounds?
Tried with several nuget versions.
Get the same problem using MSBuild runner and Visual Studio (sln) runner.
Please use the .NET runner with msbuild command instead of MSBuild or Visual Studio (sln) runners.