msbuild and dotnet load different versions of Sdk.targets





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















When I run msbuild /bl /v:q /nologo /restore it loads Sdk.props from c:Program Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdkSdk



However, when I run dotnet /bl /v:q /nologo on the same exact machine I can see that Sdk.props is loaded from c:Program Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkSdk



Why is the difference? How can I cause dotnet to load the same Sdk as msbuild?



The project file is this:



<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DbUpgradeApi" Version="1.0.363.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
</ItemGroup>
</Project>


EDIT 1



C:xyzLogDbUpgradeProgress [master ≡]> dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.1.502
Commit: c74ce8f29f

Runtime Environment:
OS Name: Windows
OS Version: 10.0.16299
OS Platform: Windows
RID: win10-x64
Base Path: C:Program Filesdotnetsdk2.1.502

Host (useful for support):
Version: 2.1.6
Commit: 3f4f8eebd8

.NET Core SDKs installed:
1.0.0-preview2-003131 [C:Program Filesdotnetsdk]
2.1.4 [C:Program Filesdotnetsdk]
2.1.403 [C:Program Filesdotnetsdk]
2.1.500 [C:Program Filesdotnetsdk]
2.1.502 [C:Program Filesdotnetsdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.6 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.6 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.1 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.0.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.6 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
C:xyzLogDbUpgradeProgress [master ≡]> Test-Path global.json
False
C:xyzLogDbUpgradeProgress [master ≡]> Test-Path ..global.json
False
C:xyzLogDbUpgradeProgress [master ≡]> Test-Path ....global.json
False
C:xyzLogDbUpgradeProgress [master ≡]>


EDIT 2



To demonstrate the point that builds work differently:



C:xyzLogDbUpgradeProgress [master ≡]> msbuild /v:diag > msbuild.diag.log
C:xyzLogDbUpgradeProgress [master ≡ +1 ~0 -0 !]> dotnet build /v:diag > dotnet.diag.log
C:xyzLogDbUpgradeProgress [master ≡ +2 ~0 -0 !]> cat .msbuild.diag.log | sls "bSdk.targets" | select -First 1

Property reassignment: $(MSBuildAllProjects)=";C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdkSdkSdk.props;C:xyzLogDbUpgradeProgressDirectory.Build.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.DefaultItems.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.SupportedTargetFrameworks.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.CSharp.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdkSdkSdk.targets" (previous value: ";C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdkSdkSdk.props;C:xyzLogDbUpgradeProgressDirectory.Build.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.DefaultItems.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.SupportedTargetFrameworks.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.CSharp.props") at C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdkSdkSdk.targets (15,5)


C:xyzLogDbUpgradeProgress [master ≡ +2 ~0 -0 !]> cat .dotnet.diag.log | sls "bSdk.targets" | select -First 1

Property reassignment: $(MSBuildAllProjects)=";c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkSdkSdk.props;C:xyzLogDbUpgradeProgressDirectory.Build.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.DefaultItems.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.SupportedTargetFrameworks.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.CSharp.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkSdkSdk.targets" (previous value: ";c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkSdkSdk.props;C:xyzLogDbUpgradeProgressDirectory.Build.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.DefaultItems.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.SupportedTargetFrameworks.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.CSharp.props") at c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkSdkSdk.targets (15,5)


C:xyzLogDbUpgradeProgress [master ≡ +2 ~0 -0 !]> cat .dotnet.diag.log | sls -SimpleMatch "2.1.502SdksMicrosoft.NET.SdkSdkSdk.target
s" | select -First 1
C:xyzLogDbUpgradeProgress [master ≡ +2 ~0 -0 !]>


As you can see the diag log of msbuild reference Sdk.targets from 2.1.502 whereas the diag build of dotnet never references that version and instead goes for 2.1.4



EDIT 3



Another way to recognize the difference is by passing the SourceRevisionId property. The newer Sdk.Targets makes use of it, the older does not. Please, observe (using another project):



C:xyzDbUpgradeApi [master ≡]> git clean -qdfx
C:xyzDbUpgradeApi [master ≡]> msbuild /restore /v:q /p:SourceRevisionId=123
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

C:xyzDbUpgradeApi [master ≡]> (dir .srcbinDebugnet452DbUpgradeApi.dll).VersionInfo.ProductVersion
1.0.0+123
C:xyzDbUpgradeApi [master ≡]> git clean -qdfx
C:xyzDbUpgradeApi [master ≡]> dotnet build /v:q /p:SourceRevisionId=123
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.


Build succeeded.
0 Warning(s)
0 Error(s)

Time Elapsed 00:00:01.15
C:xyzDbUpgradeApi [master ≡]> (dir .srcbinDebugnet452DbUpgradeApi.dll).VersionInfo.ProductVersion
1.0.0
C:xyzDbUpgradeApi [master ≡]>


One can see that dotnet invokes a different version of msbuild - 15.9.20+g88f5fadfbe vs 15.9.21+g9802d43bc3. But I do not think it is a problem, since this is the msbuild.dll from C:Program Filesdotnetsdk2.1.502 which seems to be the right location.










share|improve this question

























  • does dotnet --info show the installed 2.1.502 SDK? is there a global.json file in the directory hierarchy?

    – Martin Ullrich
    Jan 4 at 15:38











  • Added the information to the post. Thank you for responding.

    – mark
    Jan 4 at 15:49











  • Is there anything else I can do to help you to help me?

    – mark
    Jan 6 at 15:13


















0















When I run msbuild /bl /v:q /nologo /restore it loads Sdk.props from c:Program Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdkSdk



However, when I run dotnet /bl /v:q /nologo on the same exact machine I can see that Sdk.props is loaded from c:Program Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkSdk



Why is the difference? How can I cause dotnet to load the same Sdk as msbuild?



The project file is this:



<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DbUpgradeApi" Version="1.0.363.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
</ItemGroup>
</Project>


EDIT 1



C:xyzLogDbUpgradeProgress [master ≡]> dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.1.502
Commit: c74ce8f29f

Runtime Environment:
OS Name: Windows
OS Version: 10.0.16299
OS Platform: Windows
RID: win10-x64
Base Path: C:Program Filesdotnetsdk2.1.502

Host (useful for support):
Version: 2.1.6
Commit: 3f4f8eebd8

.NET Core SDKs installed:
1.0.0-preview2-003131 [C:Program Filesdotnetsdk]
2.1.4 [C:Program Filesdotnetsdk]
2.1.403 [C:Program Filesdotnetsdk]
2.1.500 [C:Program Filesdotnetsdk]
2.1.502 [C:Program Filesdotnetsdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.6 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.6 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.1 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.0.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.6 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
C:xyzLogDbUpgradeProgress [master ≡]> Test-Path global.json
False
C:xyzLogDbUpgradeProgress [master ≡]> Test-Path ..global.json
False
C:xyzLogDbUpgradeProgress [master ≡]> Test-Path ....global.json
False
C:xyzLogDbUpgradeProgress [master ≡]>


EDIT 2



To demonstrate the point that builds work differently:



C:xyzLogDbUpgradeProgress [master ≡]> msbuild /v:diag > msbuild.diag.log
C:xyzLogDbUpgradeProgress [master ≡ +1 ~0 -0 !]> dotnet build /v:diag > dotnet.diag.log
C:xyzLogDbUpgradeProgress [master ≡ +2 ~0 -0 !]> cat .msbuild.diag.log | sls "bSdk.targets" | select -First 1

Property reassignment: $(MSBuildAllProjects)=";C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdkSdkSdk.props;C:xyzLogDbUpgradeProgressDirectory.Build.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.DefaultItems.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.SupportedTargetFrameworks.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.CSharp.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdkSdkSdk.targets" (previous value: ";C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdkSdkSdk.props;C:xyzLogDbUpgradeProgressDirectory.Build.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.DefaultItems.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.SupportedTargetFrameworks.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.CSharp.props") at C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdkSdkSdk.targets (15,5)


C:xyzLogDbUpgradeProgress [master ≡ +2 ~0 -0 !]> cat .dotnet.diag.log | sls "bSdk.targets" | select -First 1

Property reassignment: $(MSBuildAllProjects)=";c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkSdkSdk.props;C:xyzLogDbUpgradeProgressDirectory.Build.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.DefaultItems.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.SupportedTargetFrameworks.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.CSharp.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkSdkSdk.targets" (previous value: ";c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkSdkSdk.props;C:xyzLogDbUpgradeProgressDirectory.Build.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.DefaultItems.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.SupportedTargetFrameworks.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.CSharp.props") at c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkSdkSdk.targets (15,5)


C:xyzLogDbUpgradeProgress [master ≡ +2 ~0 -0 !]> cat .dotnet.diag.log | sls -SimpleMatch "2.1.502SdksMicrosoft.NET.SdkSdkSdk.target
s" | select -First 1
C:xyzLogDbUpgradeProgress [master ≡ +2 ~0 -0 !]>


As you can see the diag log of msbuild reference Sdk.targets from 2.1.502 whereas the diag build of dotnet never references that version and instead goes for 2.1.4



EDIT 3



Another way to recognize the difference is by passing the SourceRevisionId property. The newer Sdk.Targets makes use of it, the older does not. Please, observe (using another project):



C:xyzDbUpgradeApi [master ≡]> git clean -qdfx
C:xyzDbUpgradeApi [master ≡]> msbuild /restore /v:q /p:SourceRevisionId=123
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

C:xyzDbUpgradeApi [master ≡]> (dir .srcbinDebugnet452DbUpgradeApi.dll).VersionInfo.ProductVersion
1.0.0+123
C:xyzDbUpgradeApi [master ≡]> git clean -qdfx
C:xyzDbUpgradeApi [master ≡]> dotnet build /v:q /p:SourceRevisionId=123
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.


Build succeeded.
0 Warning(s)
0 Error(s)

Time Elapsed 00:00:01.15
C:xyzDbUpgradeApi [master ≡]> (dir .srcbinDebugnet452DbUpgradeApi.dll).VersionInfo.ProductVersion
1.0.0
C:xyzDbUpgradeApi [master ≡]>


One can see that dotnet invokes a different version of msbuild - 15.9.20+g88f5fadfbe vs 15.9.21+g9802d43bc3. But I do not think it is a problem, since this is the msbuild.dll from C:Program Filesdotnetsdk2.1.502 which seems to be the right location.










share|improve this question

























  • does dotnet --info show the installed 2.1.502 SDK? is there a global.json file in the directory hierarchy?

    – Martin Ullrich
    Jan 4 at 15:38











  • Added the information to the post. Thank you for responding.

    – mark
    Jan 4 at 15:49











  • Is there anything else I can do to help you to help me?

    – mark
    Jan 6 at 15:13














0












0








0








When I run msbuild /bl /v:q /nologo /restore it loads Sdk.props from c:Program Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdkSdk



However, when I run dotnet /bl /v:q /nologo on the same exact machine I can see that Sdk.props is loaded from c:Program Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkSdk



Why is the difference? How can I cause dotnet to load the same Sdk as msbuild?



The project file is this:



<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DbUpgradeApi" Version="1.0.363.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
</ItemGroup>
</Project>


EDIT 1



C:xyzLogDbUpgradeProgress [master ≡]> dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.1.502
Commit: c74ce8f29f

Runtime Environment:
OS Name: Windows
OS Version: 10.0.16299
OS Platform: Windows
RID: win10-x64
Base Path: C:Program Filesdotnetsdk2.1.502

Host (useful for support):
Version: 2.1.6
Commit: 3f4f8eebd8

.NET Core SDKs installed:
1.0.0-preview2-003131 [C:Program Filesdotnetsdk]
2.1.4 [C:Program Filesdotnetsdk]
2.1.403 [C:Program Filesdotnetsdk]
2.1.500 [C:Program Filesdotnetsdk]
2.1.502 [C:Program Filesdotnetsdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.6 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.6 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.1 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.0.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.6 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
C:xyzLogDbUpgradeProgress [master ≡]> Test-Path global.json
False
C:xyzLogDbUpgradeProgress [master ≡]> Test-Path ..global.json
False
C:xyzLogDbUpgradeProgress [master ≡]> Test-Path ....global.json
False
C:xyzLogDbUpgradeProgress [master ≡]>


EDIT 2



To demonstrate the point that builds work differently:



C:xyzLogDbUpgradeProgress [master ≡]> msbuild /v:diag > msbuild.diag.log
C:xyzLogDbUpgradeProgress [master ≡ +1 ~0 -0 !]> dotnet build /v:diag > dotnet.diag.log
C:xyzLogDbUpgradeProgress [master ≡ +2 ~0 -0 !]> cat .msbuild.diag.log | sls "bSdk.targets" | select -First 1

Property reassignment: $(MSBuildAllProjects)=";C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdkSdkSdk.props;C:xyzLogDbUpgradeProgressDirectory.Build.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.DefaultItems.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.SupportedTargetFrameworks.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.CSharp.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdkSdkSdk.targets" (previous value: ";C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdkSdkSdk.props;C:xyzLogDbUpgradeProgressDirectory.Build.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.DefaultItems.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.SupportedTargetFrameworks.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.CSharp.props") at C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdkSdkSdk.targets (15,5)


C:xyzLogDbUpgradeProgress [master ≡ +2 ~0 -0 !]> cat .dotnet.diag.log | sls "bSdk.targets" | select -First 1

Property reassignment: $(MSBuildAllProjects)=";c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkSdkSdk.props;C:xyzLogDbUpgradeProgressDirectory.Build.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.DefaultItems.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.SupportedTargetFrameworks.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.CSharp.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkSdkSdk.targets" (previous value: ";c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkSdkSdk.props;C:xyzLogDbUpgradeProgressDirectory.Build.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.DefaultItems.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.SupportedTargetFrameworks.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.CSharp.props") at c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkSdkSdk.targets (15,5)


C:xyzLogDbUpgradeProgress [master ≡ +2 ~0 -0 !]> cat .dotnet.diag.log | sls -SimpleMatch "2.1.502SdksMicrosoft.NET.SdkSdkSdk.target
s" | select -First 1
C:xyzLogDbUpgradeProgress [master ≡ +2 ~0 -0 !]>


As you can see the diag log of msbuild reference Sdk.targets from 2.1.502 whereas the diag build of dotnet never references that version and instead goes for 2.1.4



EDIT 3



Another way to recognize the difference is by passing the SourceRevisionId property. The newer Sdk.Targets makes use of it, the older does not. Please, observe (using another project):



C:xyzDbUpgradeApi [master ≡]> git clean -qdfx
C:xyzDbUpgradeApi [master ≡]> msbuild /restore /v:q /p:SourceRevisionId=123
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

C:xyzDbUpgradeApi [master ≡]> (dir .srcbinDebugnet452DbUpgradeApi.dll).VersionInfo.ProductVersion
1.0.0+123
C:xyzDbUpgradeApi [master ≡]> git clean -qdfx
C:xyzDbUpgradeApi [master ≡]> dotnet build /v:q /p:SourceRevisionId=123
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.


Build succeeded.
0 Warning(s)
0 Error(s)

Time Elapsed 00:00:01.15
C:xyzDbUpgradeApi [master ≡]> (dir .srcbinDebugnet452DbUpgradeApi.dll).VersionInfo.ProductVersion
1.0.0
C:xyzDbUpgradeApi [master ≡]>


One can see that dotnet invokes a different version of msbuild - 15.9.20+g88f5fadfbe vs 15.9.21+g9802d43bc3. But I do not think it is a problem, since this is the msbuild.dll from C:Program Filesdotnetsdk2.1.502 which seems to be the right location.










share|improve this question
















When I run msbuild /bl /v:q /nologo /restore it loads Sdk.props from c:Program Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdkSdk



However, when I run dotnet /bl /v:q /nologo on the same exact machine I can see that Sdk.props is loaded from c:Program Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkSdk



Why is the difference? How can I cause dotnet to load the same Sdk as msbuild?



The project file is this:



<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DbUpgradeApi" Version="1.0.363.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
</ItemGroup>
</Project>


EDIT 1



C:xyzLogDbUpgradeProgress [master ≡]> dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.1.502
Commit: c74ce8f29f

Runtime Environment:
OS Name: Windows
OS Version: 10.0.16299
OS Platform: Windows
RID: win10-x64
Base Path: C:Program Filesdotnetsdk2.1.502

Host (useful for support):
Version: 2.1.6
Commit: 3f4f8eebd8

.NET Core SDKs installed:
1.0.0-preview2-003131 [C:Program Filesdotnetsdk]
2.1.4 [C:Program Filesdotnetsdk]
2.1.403 [C:Program Filesdotnetsdk]
2.1.500 [C:Program Filesdotnetsdk]
2.1.502 [C:Program Filesdotnetsdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.6 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.6 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.1 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.0.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.6 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
C:xyzLogDbUpgradeProgress [master ≡]> Test-Path global.json
False
C:xyzLogDbUpgradeProgress [master ≡]> Test-Path ..global.json
False
C:xyzLogDbUpgradeProgress [master ≡]> Test-Path ....global.json
False
C:xyzLogDbUpgradeProgress [master ≡]>


EDIT 2



To demonstrate the point that builds work differently:



C:xyzLogDbUpgradeProgress [master ≡]> msbuild /v:diag > msbuild.diag.log
C:xyzLogDbUpgradeProgress [master ≡ +1 ~0 -0 !]> dotnet build /v:diag > dotnet.diag.log
C:xyzLogDbUpgradeProgress [master ≡ +2 ~0 -0 !]> cat .msbuild.diag.log | sls "bSdk.targets" | select -First 1

Property reassignment: $(MSBuildAllProjects)=";C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdkSdkSdk.props;C:xyzLogDbUpgradeProgressDirectory.Build.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.DefaultItems.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.SupportedTargetFrameworks.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.CSharp.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdkSdkSdk.targets" (previous value: ";C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdkSdkSdk.props;C:xyzLogDbUpgradeProgressDirectory.Build.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.DefaultItems.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.SupportedTargetFrameworks.props;C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.CSharp.props") at C:Program
Filesdotnetsdk2.1.502SdksMicrosoft.NET.SdkSdkSdk.targets (15,5)


C:xyzLogDbUpgradeProgress [master ≡ +2 ~0 -0 !]> cat .dotnet.diag.log | sls "bSdk.targets" | select -First 1

Property reassignment: $(MSBuildAllProjects)=";c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkSdkSdk.props;C:xyzLogDbUpgradeProgressDirectory.Build.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.DefaultItems.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.SupportedTargetFrameworks.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.CSharp.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkSdkSdk.targets" (previous value: ";c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkSdkSdk.props;C:xyzLogDbUpgradeProgressDirectory.Build.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.DefaultItems.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.SupportedTargetFrameworks.props;c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkbuildMicrosoft.NET.Sdk.CSharp.props") at c:Program
Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkSdkSdk.targets (15,5)


C:xyzLogDbUpgradeProgress [master ≡ +2 ~0 -0 !]> cat .dotnet.diag.log | sls -SimpleMatch "2.1.502SdksMicrosoft.NET.SdkSdkSdk.target
s" | select -First 1
C:xyzLogDbUpgradeProgress [master ≡ +2 ~0 -0 !]>


As you can see the diag log of msbuild reference Sdk.targets from 2.1.502 whereas the diag build of dotnet never references that version and instead goes for 2.1.4



EDIT 3



Another way to recognize the difference is by passing the SourceRevisionId property. The newer Sdk.Targets makes use of it, the older does not. Please, observe (using another project):



C:xyzDbUpgradeApi [master ≡]> git clean -qdfx
C:xyzDbUpgradeApi [master ≡]> msbuild /restore /v:q /p:SourceRevisionId=123
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

C:xyzDbUpgradeApi [master ≡]> (dir .srcbinDebugnet452DbUpgradeApi.dll).VersionInfo.ProductVersion
1.0.0+123
C:xyzDbUpgradeApi [master ≡]> git clean -qdfx
C:xyzDbUpgradeApi [master ≡]> dotnet build /v:q /p:SourceRevisionId=123
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.


Build succeeded.
0 Warning(s)
0 Error(s)

Time Elapsed 00:00:01.15
C:xyzDbUpgradeApi [master ≡]> (dir .srcbinDebugnet452DbUpgradeApi.dll).VersionInfo.ProductVersion
1.0.0
C:xyzDbUpgradeApi [master ≡]>


One can see that dotnet invokes a different version of msbuild - 15.9.20+g88f5fadfbe vs 15.9.21+g9802d43bc3. But I do not think it is a problem, since this is the msbuild.dll from C:Program Filesdotnetsdk2.1.502 which seems to be the right location.







c# .net msbuild






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 6 at 16:00







mark

















asked Jan 4 at 4:47









markmark

20.2k56190382




20.2k56190382













  • does dotnet --info show the installed 2.1.502 SDK? is there a global.json file in the directory hierarchy?

    – Martin Ullrich
    Jan 4 at 15:38











  • Added the information to the post. Thank you for responding.

    – mark
    Jan 4 at 15:49











  • Is there anything else I can do to help you to help me?

    – mark
    Jan 6 at 15:13



















  • does dotnet --info show the installed 2.1.502 SDK? is there a global.json file in the directory hierarchy?

    – Martin Ullrich
    Jan 4 at 15:38











  • Added the information to the post. Thank you for responding.

    – mark
    Jan 4 at 15:49











  • Is there anything else I can do to help you to help me?

    – mark
    Jan 6 at 15:13

















does dotnet --info show the installed 2.1.502 SDK? is there a global.json file in the directory hierarchy?

– Martin Ullrich
Jan 4 at 15:38





does dotnet --info show the installed 2.1.502 SDK? is there a global.json file in the directory hierarchy?

– Martin Ullrich
Jan 4 at 15:38













Added the information to the post. Thank you for responding.

– mark
Jan 4 at 15:49





Added the information to the post. Thank you for responding.

– mark
Jan 4 at 15:49













Is there anything else I can do to help you to help me?

– mark
Jan 6 at 15:13





Is there anything else I can do to help you to help me?

– mark
Jan 6 at 15:13












1 Answer
1






active

oldest

votes


















0














I found out that MSBuildSDKsPath environment variable was set on my machine to c:Program Filesdotnetsdk2.1.4Sdks



It is a mystery to me why this is so. If I remove it, then the right Sdk is used, i.e. 2.1.502.



As a workaround I am adding $env:MSBuildSDKsPath = $null to my build script.






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54033254%2fmsbuild-and-dotnet-load-different-versions-of-sdk-targets%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I found out that MSBuildSDKsPath environment variable was set on my machine to c:Program Filesdotnetsdk2.1.4Sdks



    It is a mystery to me why this is so. If I remove it, then the right Sdk is used, i.e. 2.1.502.



    As a workaround I am adding $env:MSBuildSDKsPath = $null to my build script.






    share|improve this answer




























      0














      I found out that MSBuildSDKsPath environment variable was set on my machine to c:Program Filesdotnetsdk2.1.4Sdks



      It is a mystery to me why this is so. If I remove it, then the right Sdk is used, i.e. 2.1.502.



      As a workaround I am adding $env:MSBuildSDKsPath = $null to my build script.






      share|improve this answer


























        0












        0








        0







        I found out that MSBuildSDKsPath environment variable was set on my machine to c:Program Filesdotnetsdk2.1.4Sdks



        It is a mystery to me why this is so. If I remove it, then the right Sdk is used, i.e. 2.1.502.



        As a workaround I am adding $env:MSBuildSDKsPath = $null to my build script.






        share|improve this answer













        I found out that MSBuildSDKsPath environment variable was set on my machine to c:Program Filesdotnetsdk2.1.4Sdks



        It is a mystery to me why this is so. If I remove it, then the right Sdk is used, i.e. 2.1.502.



        As a workaround I am adding $env:MSBuildSDKsPath = $null to my build script.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 7 at 4:38









        markmark

        20.2k56190382




        20.2k56190382
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54033254%2fmsbuild-and-dotnet-load-different-versions-of-sdk-targets%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas