Auto restore does not work for .NET Core projects when building via MSBuild
See original GitHub issueDescription
I have .NET Core solution with netstandard2.0
project using Paket to manage dependencies. I followed instructions on https://fsprojects.github.io/Paket/paket-and-dotnet-cli.html to setup automatic restore of packages. When I build solution from Visual Studio it works fine, but when I build it from command line on CI server using msbuild solution.sln
it fails with:
C:\Program Files\dotnet\sdk\2.0.0\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(323,5): er
ror : Assets file 'e:\Temp\PaketTest\PaketRestoreTest\TestProject\obj\project.assets.json' not found. Run a NuGet packa
ge restore to generate this file. [e:\Temp\PaketTest\PaketRestoreTest\TestProject\TestProject.csproj]
Repro steps
I attached PaketRestoreTest.zip with sample solution to reproduce this issue.
- Have Visual Studio 2017 Update 3 and .NET Core SDK 2.0
- Extract attached solution
- Open Visual Studio Command Prompt and run
msbuild PaketRestoreTest.sln
Expected behavior
I would expect that building from command line properly restores packages and build succeeds.
Actual behavior
Build from command line fails, unless you explicitly call msbuild PaketRestoreTest.sln /t:Restore
or dotnet restore
before calling msbuild PaketRestoreTest.sln
.
Known workarounds
Call msbuild PaketRestoreTest.sln /t:Restore
or dotnet restore
before calling msbuild PaketRestoreTest.sln
.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:8 (4 by maintainers)
Top GitHub Comments
I’m using common build scripts using
msbuild
. I could do conditional branch to build some projects usingdotnet build
but then I rather add conditional step to callmsbuild /t:Restore
(as I did as the workaround anyway).dotnet build
will auto-restore,msbuild foo.csproj
does not currently.