Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSBuild error: "The SDK 'Microsoft.NET.Sdk.Web' specified could not be found." #57

Closed
artiomchi opened this issue Aug 2, 2017 · 23 comments

Comments

@artiomchi
Copy link
Member

Seems like the MSBuild/dotnet team has made some changes which has broken the build process once again. This is affecting a number of other projects, so it's not limited to us. One possible reason is that this was introduced in the dotnet core 2.0 preview 2.

I'll be investigating it deeper, and hopefully will find either a way to avoid the issue, or find a workaround for it. Until then, the build might fail on your machines.

@artiomchi
Copy link
Member Author

A quick search shows these issues on the topic:

While not matching the error word by word in a couple cases, they seem to be based around the same issue.

@artiomchi
Copy link
Member Author

So here's a fun thing.. I started with a new build machine, installed the latest version of VS 2017 (15.2 stable, Community), and the project built fine. I then installed .NET Core 2.0, and the project still worked. I couldn't make .net core 2.0 projects, since that requires the 15.3 Preview version, so I installed that, and the project STILL built fine. When I upgraded it to netstandard2.0, and added a couple hacks, it still worked.

On my main build machine though, the project fails to build, even the main branch. My guess is that one of the VS installs has obviously failed to add/configure something, hence it's causing this issue. Hopefully it'll be fixed before the final release of 15.3

In the meantime, I'll see what I can do about comparing the two environments, maybe I'll find what's different between the two

@artiomchi
Copy link
Member Author

There seem to be some issue that was caused by installing either VS 15.3 preview or .NET Core 2.0 preview.

While the project works perfectly fine on my laptop, where I just had a clean install of both, my desktop has lived through several preview builds of .NET Core and VS 15, and something has clearly gone wrong there.

@philcontrolf1
Copy link

I don't think dotnet/cli#6178 is actually relevant here - that's been present since before 2.0 and is caused by the Docker SDK not being open-source so not shipped with dotnet itself.

@valeriob
Copy link
Contributor

@artiomchi I had the same experience, i also tried to completely remove vs 15.3 preview but it still does not work.

@artiomchi
Copy link
Member Author

@philcontrolf1 Ah, I guess it's not then.. I thought it seemed somewhat similar, hence linking it here

@valeriob I just managed to make my main environment work again. Like I said, I had VS 15.3 installed for some time, and over time accumulated several versions of .NET Core SDK.

What I just did was go to Programs and Features, and deleted ALL versions of .NET Core SDK - I had almost 10 of them, ranging from 1.0 to 1.1.0 (various final and early builds), as well as the 2.0 preview 2 one. Afterwards I ran a Visual Studio repair (to re-install .NET Core 1.1 SDK that comes with it), and then ran the .NET Core SDK 2.0 install on top.

I believe I have a working build environment once again. At least it builds the project successfully!

Could you confirm you can achieve the same on your side?

@valeriob
Copy link
Contributor

@artiomchi i will as soon as possible.
so you had vs 15.2 and 15.3 installed, you removed all .net core sdks and repaired 15.3 or 15.2 ?

@artiomchi
Copy link
Member Author

Pretty much, yes. I ran the repair on both of them. 15.2 failed the repair, missing some VS components (I might reinstall it later), but 15.3 ran the repair successfully.

Bad news is - while it allows me to build the project, I just realised that running R4MVC still fails (since it depends on MSBuild working correctly), so something's still messed up there :(

That's just disappointing

@valeriob
Copy link
Contributor

Yep i've always been able to compile it, i made the same procedure, but still no luck, running the tool fails to find an msbuild file

@valeriob
Copy link
Contributor

I just tried the new bits (Vs 15.3, netcore 2.0, aspnetcore 2.0 etc..) no luck, same problem

@philcontrolf1
Copy link

There's a potentially relevant comment from "Joe Morris (MSFT)" on the 15.3 release announcement:

We’ve seen this in two cases. The first is if an old preview of the 1.0 CLI is still installed on the machine. Please check to see if you have any old 1.x CLIs still installed. The second case is if the CLI is not correctly on the path. Please open a developer command prompt and inspect the PATH variable to make sure that “C:\Program Files\dotnet” appears on the path before any other entries that point to sub-directories of the “dotnet” folder.

Worth checking if you've got an 1.0 previews installed?

@valeriob
Copy link
Contributor

Hi @philcontrolf1 i had, but still no luck (and in more than one machine, both with vs 2015 and 2017):
without setting env variable MSBuildSdksPath=C:\Program Files\dotnet\sdk\2.0.0\Sdks
i get this error :

Msbuild failed when processing the file 'C:\Users\Valerio\Downloads\R4MVC-feature-dotnet-core-2\R4MVC-feature-dotnet-core-2\src\R4MvcHostApp\R4MvcHostApp.csproj' with message: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found. C:\Users\Valerio\Downloads\R4MVC-feature-dotnet-core-2\R4MVC-feature-dotnet-core-2\src\R4MvcHostApp\R4MvcHostApp.csproj

if i set the env variable MSBuildSdksPath=C:\Program Files\dotnet\sdk\2.0.0\Sdks
i get this error :

Msbuild failed when processing the file 'C:\Users\Valerio\Downloads\R4MVC-feature-dotnet-core-2\R4MVC-feature-dotnet-core-2\src\R4MvcHostApp\R4MvcHostApp.csproj' with message: The imported project "C:\Program Files (x86)\MSBuild\2.0\Microsoft.Common.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. C:\Program Files\dotnet\sdk\2.0.0\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props

Why in the universe does it look for msbuild 2.0 !?!? Wasn't every version supposed to be completely isolated ?

@artiomchi
Copy link
Member Author

@philcontrolf1 Annoyingly enough, I just uninstalled VS 2017 preview and updated VS 2017 to 15.3 on my secondary dev machine (clean install a couple weeks ago), which never had pre-release 1.x CLIs on it. Then installed the .NET Core 2.0 SDK

After doing it this morning, I started having similar issues on that machine, with MSBuild completely failing to find it's Sdk.props. So that's definitely not related to previous builds of dotnet cli.

And yes, the dotnet path is in my Path :)

@valeriob Yup, been having the same issue before.. Now I've got three separate machines complaining about it :((((

@artiomchi
Copy link
Member Author

So far, my best guess as to why this is happening is that uninstalling VS may remove something that MSBuild uses, and whatever it is - it's not restored during a VS install / repair.

Unfortunately, I've got 3 different environments that have the same issue now, and I can't run R4MVC on any of them. My choices at this point is to either format one of the machines to get a new clean environment, or spin up a VM, and either code there, or see if I can replicate / compare the environments to see what's the difference.

I wish the MSBuild team actually put some effort into figuring this out, as seems like it's been an issue for many for a LONG time =/

@valeriob
Copy link
Contributor

valeriob commented Aug 16, 2017

/Agree
have you found any issue on any ms repository that can be reconducted to this issue ?
I'll try the clean vm asap

@valeriob
Copy link
Contributor

I just created an azure vm with just vs 2017, updated to 15.3 and i could reproduce the same problem.

@sirphilliptubell
Copy link

I had the same problem but I was getting "Microsoft.NET.Sdk" instead of "Microsoft.NET.Sdk.Web". This was happening when I tried to use MSBuildWorkspace.Create().OpenSolutionAsync(...). I set the MSBuildSdksPath environment variable as mentioned above and got the same error referring to MSBuild 2.0. This all started happening after updating to VS 15.3, and even happened with 15.3.1 which just came out. My only resort until a fix seems to be to reinstall 15.1. I can't seem to find a way to upgrade to only 15.2 as I can't find the feed url to pass into the vs installer.

@artiomchi
Copy link
Member Author

Finally tracked down the issue - it's dotnet/msbuild#2369 and the solution is to set the VSINSTALLDIR environment variable to the path to your VS installation (i.e. C:\Program Files (x86)\Microsoft Visual Studio\2017\Community)

Currently I'll set it in my environment, which makes running R4MVC possible, but hopefully MS will fix it in an upcoming release!

@artiomchi
Copy link
Member Author

Better yet, I've added code that will automatically try to detect the path of a local VS installation, to remove the need to add the env variable. This should make it possible to use the plugin without any modifications.

When MSBuild patches the bug, we'll be able to remove this code. I'll probably add this to the alpha build soon as well, to make it universally useable

@larsw
Copy link

larsw commented Aug 22, 2017

Same issue for Microsoft.Docker.Sdk references in .dcproj (Docker project files). Tried setting the VSINSTALLDIR, but didn't work as a workaround.

@artiomchi
Copy link
Member Author

@larsw did you try setting both the VSINSTALLDIR and VisualStudioVersion (to "15.0") variables? Seems like the bug partially stems from incorrectly parsing the VS version number

@artiomchi
Copy link
Member Author

Build 1.0.0-alpha1-00171 should now be available in NuGet. It has the autodetection code that should make this the first self contained and working build that works on the latest version of VS.

@philcontrolf1
Copy link

@larsw That one is dotnet/cli#6178 as linked above - the "root cause" is that the Docker SDK isn't open source so can't be shipped with the CLI - there's a workaround in that thread. We're getting little traction from anyone inside Microsoft on any sort of fix unfortunately :-(

artiomchi added a commit that referenced this issue Dec 8, 2017
…patched). Also fixes #82

! Fixing typo (fixes #85)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants