My project was building without errors but with a warning
NETSDK1071 A PackageReference to 'Microsoft.AspNetCore.App' specified a Version of
2.1.1
. Specifying the version of this package is not recommended. For more information, see https://aka.ms/sdkimplicitrefs
So I edited the project and changed
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.1"/>
to
<PackageReference Include="Microsoft.AspNetCore.App" />
I pushed the code which then triggers devops to build.
However in Devops I then got the following build error
The nuget command failed with exit code(1) and error(NU1607: Version conflict detected for Microsoft.AspNetCore.Razor.Language. Reference the package directly from the project to resolve this issue.
ServerSideTests (>= 1.0.0) -> ApiForMe3 (>= 1.0.0) -> Microsoft.VisualStudio.Web.CodeGeneration.Design (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGenerators.Mvc (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration.Core (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration.Templating (>= 2.1.6) -> Microsoft.AspNetCore.Razor.Language (>= 2.1.1)
ServerSideTests (>= 1.0.0) -> Microsoft.AspNetCore.App (>= 2.1.0) -> Microsoft.AspNetCore.Razor.Language (>= 2.1.0).
Errors in D:\a\1\s\ServerSideTests\ServerSideTests.csproj
NU1607: Version conflict detected for Microsoft.AspNetCore.Razor.Language. Reference the package directly from the project to resolve this issue.
ServerSideTests (>= 1.0.0) -> ApiForMe3 (>= 1.0.0) -> Microsoft.VisualStudio.Web.CodeGeneration.Design (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGenerators.Mvc (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration.Core (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration.Templating (>= 2.1.6) -> Microsoft.AspNetCore.Razor.Language (>= 2.1.1)
ServerSideTests (>= 1.0.0) -> Microsoft.AspNetCore.App (>= 2.1.0) -> Microsoft.AspNetCore.Razor.Language (>= 2.1.0).)
Packages failed to restore
Why does the build fail in Devops but not on my local machine running VS2017 15.9.6 ?
looking up NU1607 I see
NU1107 (Previously NU1607) Issue Unable to resolve dependency constraints between packages.
Common causes Packages with dependency constraints on exact versions do not allow other packages to increase the version if needed. Example Version conflict detected for NuGet.Versioning. Reference the package directly from the project to resolve this issue. NuGet.Packaging 3.5.0 -> NuGet.Versioning (= 3.5.0) NuGet.Configuration 4.0.0 -> NuGet.Versioning (= 4.0.0)
Checking the sdk versions on my machine
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional>dotnet --list-sdks
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.400 [C:\Program Files\dotnet\sdk]
2.1.401 [C:\Program Files\dotnet\sdk]
2.1.402 [C:\Program Files\dotnet\sdk]
2.1.403 [C:\Program Files\dotnet\sdk]
2.1.500 [C:\Program Files\dotnet\sdk]
2.1.502 [C:\Program Files\dotnet\sdk]
2.1.503 [C:\Program Files\dotnet\sdk]
2.2.102 [C:\Program Files\dotnet\sdk]
global.json
to enforce a version check. – Lex Liglobal.json
with a specific version. In that way, if the target machine does not have the same SDK version, at least you or somebody else get a meaningful error message. – Lex Li