DotNetAnalyzers / StyleCopAnalyzers

An implementation of StyleCop rules using the .NET Compiler Platform
MIT License
2.64k stars 508 forks source link

Cannot build solution in Visual Studio 2019 #3107

Closed arphox closed 4 years ago

arphox commented 4 years ago

I cannot build the StyleCopAnalyzers solution using my installation of Visual Studio 2019 Community.

I downloaded the (now) latest commit (b15704e), opened StyleCopAnalyzers.sln, and all projects failed to load.

When I try to manually reload the StyleCop.Analyzers project, an error messagebox appears with the message "The operation could not be completed" and meanwhile I see the following errors in Solution tab of Output window:

e:\prog\repos\StyleCopAnalyzers\StyleCop.Analyzers\StyleCop.Analyzers\StyleCop.Analyzers.csproj : error  : The project file cannot be opened by the project system, because it is missing some critical imports or the referenced SDK cannot be found.

Detailed Information:
Unable to locate the .NET Core SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version.

I have tried to fix the problem by looking at the targeted frameworks for projects, e.g. netstandard1.1;net452 in case of StyleCop.Analyzers, but I did not find any .NET Core references that would be missing.

I have most components installed in VS19 installer, click for images ![installimg1](https://user-images.githubusercontent.com/17320094/72869078-571dc400-3ce4-11ea-9326-194d820f399d.png) ![installimg2](https://user-images.githubusercontent.com/17320094/72869094-656be000-3ce4-11ea-8e01-08d37fb5f4c3.png)

So I don't understand what could be missing that is related to .NET Core. I did not want to blindly install all legacy .NET Core versions so I am writing this issue.

Also, a "Building" part for the README would be really useful to avoid problems like this.

arphox commented 4 years ago

It seems that I have problems building other solutions as well, e.g. Newtonsoft.Json, currently investigating my installation.

arphox commented 4 years ago

I reinstalled windows 10 on my PC (not just because of this) and installed VS 19 community with a lot of workloads. I can create a lot of types of projects and open my previous ones, but not the solution in this repository, neither the Newtonsoft.Json one.

sharwell commented 4 years ago

You need the dotnet SDK listed from global.json:

https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/b15704eec6f407e39a32e78912ded87ea4c0c060/global.json#L3

arphox commented 4 years ago

Thank you, x64 and/or x86 version?

sharwell commented 4 years ago

I'm not sure it matters, but I've used the x64 version.

@jnm2 how do I make it more flexible in the selection?

arphox commented 4 years ago

After I installed the .NET Core 2.1.504 x64 package, I could build the solution. Thank you so much for your help!

jnm2 commented 4 years ago

@sharwell There's finally documentation: https://docs.microsoft.com/en-us/dotnet/core/tools/global-json?tabs=netcore3x#rollforward

I've been seeing "rollForward": "feature" the most.