0
votes

When I try to open a legacy Visual Studio solution, I get this error for all its projects (so they fail loading): ‘The imported project "C:\Program Files (x86)\MSBuild\StyleCop\v4.7\StyleCop.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.’. The line on the project file that is causing the error seems to be this one: <Import Project="$(ProgramFiles)\MSBuild\StyleCop\v4.7\StyleCop.targets" />. How can I install StyleCop so its files go to that folder? I have tried to install it on my machine both as a Nuget package and as a VS extension but none of these options put the files in that path. I have not found the MSI installer itself, only the Nuget option. One constraint I have is that I need to keep the project files as they are. I am using VS 2015.

2

2 Answers

3
votes

I couldn't find the installer, but if you go into the project file (.csproj) and comment out the line

<Import Project="C:\Program Files (x86)\MSBuild\StyleCop\v4.7\StyleCop.targets" />

you should be able to load the project.

2
votes

I finally found the installer here, I used it, it added the missing folder and this solved the issue. When installing it is important to make sure the MSBUILD option in the installer window is selected.