dotnet / core

.NET news, announcements, release notes, and more!
https://dot.net
MIT License
20.96k stars 4.91k forks source link

Build error when using .NET 5 #4559

Open PWagner1 opened 4 years ago

PWagner1 commented 4 years ago

Hi,

I'm receiving the following error while building a application for Windows: error NETSDK1045: The current .NET SDK does not support targeting .NET Core 5.0. Either target .NET Core 3.1 or lower, or use a version of the .NET SDK that supports .NET Core 5.0. I'm using preview 2, and I am currently targeting 3.1. See: https://github.com/Krypton-Suite/Standard-Toolkit/tree/dot-net-5 for complete source.

Is there anyway of resolving this?

svick commented 4 years ago

Are you sure you are using .Net SDK 5.0 Preview? What does dotnet --info print for you?

PWagner1 commented 4 years ago

Hi @svick, yes I've installed 5.0.0-preview.2.20160.6 (x86 & x64)

Annotation 2020-04-12 095110

svick commented 4 years ago

Is it possible that you have a global.json somewhere in the directory structure above your project? You can check that by running dotnet --info in your project's directory.

Also, are you building from the command line or using Visual Studio? If it's Visual Studio, I believe VS 16.6 Preview is required. Are you using that?

PWagner1 commented 4 years ago

Both yes I'm using VS 16.6 Preview & building the project & making NuGet packages via cmd. I do have the stable release of Visual Studio 16.5 installed, which I don't use. Could that be interfering? Here's the info from the directory structure.

Capture

svick commented 4 years ago

Then I'm stumped, sorry. Hopefully, someone else will be able to help you.

PWagner1 commented 4 years ago

@svick No problem, thanks anyway!

mairaw commented 4 years ago

Unfortunately, I can't repro this issue @Wagnerp.

Just downloaded your project and checked out that branch and build went fine: image

I have the same version as you: image

Maybe try installing Preview 3 that was released today and see if you still have the same issue?

PWagner1 commented 4 years ago

Hi @mairaw

Thanks, I'll check out preview 3 and will let you know what happens.

PWagner1 commented 4 years ago

Hi @mairaw

I have tried but it doesn't output any binaries. I use build.cmd & build.prj, which works fine with .NET Core 3.1 but not with .NET 5, even though I have it as a targeted framework.

mairaw commented 4 years ago

@rainersigwald is this something you can help with?

PWagner1 commented 4 years ago

Hi @mairaw

I think that I've figured out the issue.

1) I've got both the stable & preview versions of Visual Studio installed 2) I don't think it likes to build if you don't have Visual Studio installed in the default C:\Program Files (x86)\Microsoft Visual Studio\2019 directory (I always install my applications in a separate partition)

Hope this helps!

rainersigwald commented 4 years ago

@Wagnerp https://github.com/Krypton-Suite/Standard-Toolkit/blob/dot-net-5/build.cmd tries to find and invoke MSBuild.exe from a variety of locations (all in programfiles(x86)). Which one is selected in your case? If you build from the command line using dotnet build do you get the same problems?

PWagner1 commented 4 years ago

Hi @rainersigwald

I use VS Community, but I installed my environment on another partition, not C:\Program Files (x86. The dotnet build command does work, but it doesn't output any binaries. I have tested the build system does work on a VM (to eliminate the possibility of the batch file having a issue). I can verify that everything does work, providing that you install everything to their default locations.

rainersigwald commented 4 years ago

What is the exact command you're entering, and what is its output?

PWagner1 commented 4 years ago

I use build.cmd and it should output binaries to a Bin directory in the root folder.

However, it fails to build with the message error NETSDK1045: The current .NET SDK does not support targeting .NET Core 5.0. Either target .NET Core 3.1 or lower, or use a version of the .NET SDK that supports .NET Core 5.0.