Warm tip: This article is reproduced from serverfault.com, please click

Visual Studio Build Tools fails to recognize "net5.0-windows"

发布于 2020-11-27 14:31:29

Is it possible to build a .NET 5 project with the Visual Studio Build Tools? Or is my installation not working?

Note: I can't use the dotnet.exe, since i have to build with the WiX-Toolset.

Installed:

  • Microsoft (R)-Build-Engine, Version 16.7.0+b89cb5fde für .NET Framework
  • .NET SDK (gemäß "global.json"): Version: 5.0.100 Commit: 5044b93829

msbuild.exe used from C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin

Error:

 C:\Program Files\dotnet\sdk\3.1.403\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(93,5): error NETSDK1013: Der TargetFramework-Wert "net5.0-windows" wurde nicht erkann
t. Unter Umständen ist die Schreibweise nicht korrekt. Andernfalls müssen die Eigenschaften TargetFrameworkIdentifier und/oder TargetFrameworkVersion explizit angegeben werden. [C:\GitLab-Runner\builds
\mq82bps2\0\capps\developer\mfinder\MFinder\MFinder.csproj]

Also the msbuild.exe searches in the path C:\Program Files\dotnet\sdk\3.1.403\ and not C:\Program Files\dotnet\sdk\5.0.100\. Any hints on that?

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net5.0-windows</TargetFramework>
    <UseWPF>true</UseWPF>
Questioner
kuch3n
Viewed
0
Perry Qian-MSFT 2020-11-30 10:58:55

If you want to use Build Tool, you should note that .NET 5.0 is released since 16.8. So you should update your build tool to 16.8.x and then you can build .NET 5.0 projects.

Also, if you just use command line, you can directly download .NET 5.0 Sdk and then use dotnet build.

And if you installed .NET 5.0 and want to use VS IDE, you should also update VS to 16.8.x.