0

I want to build a Solution with .NET 6 Projects

I installed the .NET SDK 6.0.412 from https://dotnet.microsoft.com/en-us/download/dotnet/6.0

But I get on one system the following error:

MSB4276: The default SDK resolver failed to resolve SDK "Microsoft.NET.Sdk" because directory "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Sdks\Microsoft.NET.Sdk\Sdk" did not exist.

So I tried to add a global.json:

{
  "sdk": {
    "version": "6.0.412",
    "rollForward": "latestMinor",
  }
}

My Project File starts like this

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    <Configurations>Debug;Deploy;Release;Test</Configurations>
    <SignAssembly>true</SignAssembly>
    <AssemblyOriginatorKeyFile>StrongKey.snk</AssemblyOriginatorKeyFile>
    <NoWarn>NU1702</NoWarn>
    <OutputPath>..\..\bin\$(Configuration)\</OutputPath>
    <AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
    <TargetFrameworks>net472;net6.0-windows</TargetFrameworks>
  </PropertyGroup>
  
  <Target Name="BeforeBuild">
    <!-- $env:BUILD_VERSION, build version -->
    <PropertyGroup Condition="'$(BUILD_VERSION)' == ''">
      <BuildVersion>1.4</BuildVersion>
    </PropertyGroup>
    <PropertyGroup Condition="'$(BUILD_VERSION)' != ''">
      <BuildVersion>$(BUILD_VERSION)</BuildVersion>
    </PropertyGroup>
    <!-- year -->
    <PropertyGroup>
      <CurrentYear>$([System.DateTime]::Now.ToString(yyyy))</CurrentYear>
    </PropertyGroup>
    <!-- $env:SVN_REVISION_STRING, SVN revision number -->
    <SvnVersion Condition="'$(SVN_REVISION_STRING)' == ''" LocalPath="$(MSBuildProjectDirectory)" ToolPath="$(ProgramW6432)\TortoiseSVN\bin">
      <Output TaskParameter="Revision" PropertyName="Revision" />
    </SvnVersion>
    <PropertyGroup Condition="'$(SVN_REVISION_STRING)' != ''">
      <Revision>$(SVN_REVISION_STRING)</Revision>
    </PropertyGroup>
    <!-- create and update assemblyinfo.cs -->
    <Copy SourceFiles="Properties\AssemblyInfo.cs.tmpl" DestinationFiles="Properties\AssemblyInfo.cs" />
    <FileUpdate Files="Properties\AssemblyInfo.cs" Regex="AssemblyVersion\(&quot;.*&quot;\)" ReplacementText="AssemblyVersion(&quot;$(BuildVersion).$(Revision)&quot;)" />
    <FileUpdate Files="Properties\AssemblyInfo.cs" Regex="Assembly(Product|Title)\(&quot;.*&quot;\)" ReplacementText="Assembly$1(&quot;$(MSBuildProjectName)&quot;)" />
    <FileUpdate Files="Properties\AssemblyInfo.cs" Regex="\$YEAR\$" ReplacementText="$(CurrentYear)" />
  </Target>
  <ItemGroup>

Any ideas on how to fix this? The path it is looking for the sdk is wrong. It should be C:\Program Files\dotnet\sdk\6.0.412 How can I influence the path where it is looking for the SDK?

MarkusE
  • 545
  • 4
  • 20

1 Answers1

0

I had to install the SDK also additionaly over Visual Studio Build Tools like described here: https://stackoverflow.com/a/64679752/3405498

That solved the issue.

MarkusE
  • 545
  • 4
  • 20