none
MSBuild Task on TFS 2018 failing with the wrong .net SDK Path RRS feed

  • Question

  • I have a MSBuild task to build a service fabric project on TFS 2018 [On-Premises]. The solution builds fine locally using Visual Studio 2019 and MSBuild. It fails on the TFS Build Agent with the error..

    Error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.1. Either target .NET Core 2.1 or lower, or use a version of the .NET SDK that supports .NET Core 3.1.

    I explicitly configured the MSBuild task to use "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\msbuild.exe"

    I am using the MSBuild task with the following parameters..

    /p:Deterministic=true /t:Package /p:PackageLocation=$(build.artifactstagingdirectory)\applicationpackage

    The TFS Build agent has both Visual Studio 2017 and 2019 installed. It also has the .Net core SDK 3.1 installed. [3.1.100 version].

    For some reason the build output shows that the SDK is being picked up from "C:\Program Files\dotnet\sdk\2.1.602". It needs to use the SDK from "C:\Program Files\dotnet\sdk\3.1.100"

    How do I force MSBuild task to use the SDK from C:\Program Files\dotnet\sdk\3.1.100.

    I cannot add the "Nuget tools installer" task to the pipeline as our build agent does not have access to internet​

    NOTE: The project was building fine using MSBuild from Visual Studio 2017 build task in TFS when we were on .net core 2.2.

    We had to upgrade one the projects to .net core 3.1 and VS 2019 and it broke the build in TFS.

    Contents of SFProj File:

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets=";ValidateMSBuildFiles">
      <Import Project="..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7\build\Microsoft.VisualStudio.Azure.Fabric.Application.props" Condition="Exists('..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" />
      <PropertyGroup Label="Globals">
    <ProjectGuid>3b02cfa3-a4c3-49ea-9186-64ae171d64a7</ProjectGuid>
    <ProjectVersion>2.3</ProjectVersion>
    <MinToolsVersion>1.5</MinToolsVersion>
    <SupportedMSBuildNuGetPackageVersion>1.6.7</SupportedMSBuildNuGetPackageVersion>
    <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
      </PropertyGroup>
      <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
     </ItemGroup>
      <ItemGroup>
    <None Include="ApplicationParameters\Local.1Node.xml" />
    <None Include="ApplicationParameters\Local.5Node.xml" />
    <None Include="PublishProfiles\Local.1Node.xml" />
    <None Include="PublishProfiles\Local.5Node.xml" />
    <None Include="Scripts\Deploy-FabricApplication.ps1" />
      </ItemGroup>
      <ItemGroup>
    <Content Include="ApplicationPackageRoot\ApplicationManifest.xml" />
    <Content Include="ApplicationParameters\Params.xml" />
    <Content Include="packages.config" />
      </ItemGroup>
     <ItemGroup>
    
    <ProjectReference Include="..\Stateful1.csproj" />
    </ItemGroup>
    <Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
    <PropertyGroup>
    <ApplicationProjectTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Service Fabric Tools\Microsoft.VisualStudio.Azure.Fabric.ApplicationProject.targets</ApplicationProjectTargetsPath>
     </PropertyGroup>
    <Import Project="$(ApplicationProjectTargetsPath)" Condition="Exists('$(ApplicationProjectTargetsPath)')" />
          <Import Project="..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets" Condition="Exists('..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" />
      <Target Name="ValidateMSBuildFiles" BeforeTargets="PrepareForBuild">
    <Error Condition="!Exists('..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" Text="Unable to find the '..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7\build\Microsoft.VisualStudio.Azure.Fabric.Application.props' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package." />
    <Error Condition="!Exists('..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" Text="Unable to find the '..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package." />
      </Target>
    </Project>

    Thursday, January 9, 2020 3:02 AM

All replies

  • Hi teeboy_1975,

    Welcome to MSDN forum.

    According to your description, this issue seems to be more related to building on tfs, since our forum is discussing about the msbuild tool itself, and the tfs forum is locked, so we recommend you could go to stackoverflow with tfs tag, and then you would get dedicated support there.

    Thank you for understanding.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Friday, January 10, 2020 2:14 AM