StyleCop build sources

Jun 14, 2013 at 2:17 PM
Hi!
When I try to open StyleCop.sln in VS2010, some projects are unavailable. There is the output:
D:\Projects\stylecop_249eed5b15ed\Project\Src\AddIns\CSharp\Parser\CSharpParser.csproj : error : Unable to read the project file 'CSharpParser.csproj'.
D:\Projects\stylecop_249eed5b15ed\Tools\msbuild\StyleCop.Build.Targets(2,3): The imported project "C:\Tools\StyleCop\v4.7\StyleCop.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

D:\Projects\stylecop_249eed5b15ed\Project\Src\StyleCop\StyleCop.csproj : error : Unable to read the project file 'StyleCop.csproj'.
D:\Projects\stylecop_249eed5b15ed\Tools\msbuild\StyleCop.Build.Targets(2,3): The imported project "C:\Tools\StyleCop\v4.7\StyleCop.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

D:\Projects\stylecop_249eed5b15ed\Project\Src\AddIns\CSharp\Analyzers\CSharpAnalyzers.csproj : error : Unable to read the project file 'CSharpAnalyzers.csproj'.
D:\Projects\stylecop_249eed5b15ed\Tools\msbuild\StyleCop.Build.Targets(2,3): The imported project "C:\Tools\StyleCop\v4.7\StyleCop.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

D:\Projects\stylecop_249eed5b15ed\Project\Src\VSPackage\VSPackage.csproj : error : Unable to read the project file 'VSPackage.csproj'.
D:\Projects\stylecop_249eed5b15ed\Project\Src\VSPackage\VSPackage.csproj(192,3): The imported project "C:\Microsoft.VsSDK.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

D:\Projects\stylecop_249eed5b15ed\Project\Src\AddIns\CSharp\InternalAnalyzers\InternalAnalyzers.csproj : error : Unable to read the project file 'InternalAnalyzers.csproj'.
D:\Projects\stylecop_249eed5b15ed\Tools\msbuild\StyleCop.Build.Targets(2,3): The imported project "C:\Tools\StyleCop\v4.7\StyleCop.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

D:\Projects\stylecop_249eed5b15ed\Project\Src\SettingsEditor\SettingsEditor.csproj : error : Unable to read the project file 'SettingsEditor.csproj'.
D:\Projects\stylecop_249eed5b15ed\Tools\msbuild\StyleCop.Build.Targets(2,3): The imported project "C:\Tools\StyleCop\v4.7\StyleCop.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

D:\Projects\stylecop_249eed5b15ed\Project\Src\VSIXProject\VSIXProject.csproj : error : The project file 'D:\Projects\stylecop_249eed5b15ed\Project\Src\VSIXProject\VSIXProject.csproj' cannot be opened.

The project type is not supported by this installation.

D:\Projects\stylecop_249eed5b15ed\Project\Test\Harnesses\TestHarness\StyleCopTest.csproj : error : Unable to read the project file 'StyleCopTest.csproj'.
D:\Projects\stylecop_249eed5b15ed\Tools\msbuild\StyleCop.Build.Targets(2,3): The imported project "C:\Tools\StyleCop\v4.7\StyleCop.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

D:\Projects\stylecop_249eed5b15ed\Project\Src\AddIns\ReSharper611\ReSharper611.csproj : error : Unable to read the project file 'ReSharper611.csproj'.
D:\Projects\stylecop_249eed5b15ed\Tools\msbuild\StyleCop.Build.Targets(2,3): The imported project "C:\Tools\StyleCop\v4.7\StyleCop.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

D:\Projects\stylecop_249eed5b15ed\Project\Src\AddIns\ReSharper600\ReSharper600.csproj : error : Unable to read the project file 'ReSharper600.csproj'.
D:\Projects\stylecop_249eed5b15ed\Tools\msbuild\StyleCop.Build.Targets(2,3): The imported project "C:\Tools\StyleCop\v4.7\StyleCop.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

D:\Projects\stylecop_249eed5b15ed\Project\Src\AddIns\ReSharper513\ReSharper513.csproj : error : Unable to read the project file 'ReSharper513.csproj'.
D:\Projects\stylecop_249eed5b15ed\Tools\msbuild\StyleCop.Build.Targets(2,3): The imported project "C:\Tools\StyleCop\v4.7\StyleCop.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

D:\Projects\stylecop_249eed5b15ed\Project\Src\AddIns\ReSharper610\ReSharper610.csproj : error : Unable to read the project file 'ReSharper610.csproj'.
D:\Projects\stylecop_249eed5b15ed\Tools\msbuild\StyleCop.Build.Targets(2,3): The imported project "C:\Tools\StyleCop\v4.7\StyleCop.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

D:\Projects\stylecop_249eed5b15ed\Project\Src\AddIns\ReSharper700\ReSharper700.csproj : error : Unable to read the project file 'ReSharper700.csproj'.
D:\Projects\stylecop_249eed5b15ed\Tools\msbuild\StyleCop.Build.Targets(2,3): The imported project "C:\Tools\StyleCop\v4.7\StyleCop.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

D:\Projects\stylecop_249eed5b15ed\Project\Src\AddIns\ReSharper710\ReSharper710.csproj : error : Unable to read the project file 'ReSharper710.csproj'.
D:\Projects\stylecop_249eed5b15ed\Tools\msbuild\StyleCop.Build.Targets(2,3): The imported project "C:\Tools\StyleCop\v4.7\StyleCop.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

When I try to open Project.AutoFix, I get this output:
d:\Projects\stylecop_249eed5b15ed\Project.AutoFix\Src\StyleCop\StyleCop.csproj : error : Unable to read the project file 'StyleCop.csproj'.
d:\Projects\stylecop_249eed5b15ed\Project.AutoFix\Src\StyleCop\StyleCop.csproj(298,3): The imported project "d:\Tools\msbuild\StyleCop.Build.Targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

d:\Projects\stylecop_249eed5b15ed\Project.AutoFix\Src\VSPackage\VSPackage.csproj : error : Unable to read the project file 'VSPackage.csproj'.
d:\Projects\stylecop_249eed5b15ed\Project.AutoFix\Src\VSPackage\VSPackage.csproj(203,3): The imported project "d:\Microsoft.VsSDK.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

d:\Projects\stylecop_249eed5b15ed\Project.AutoFix\Test\Harnesses\TestHarness\StyleCopTestHarness.csproj : error : Unable to read the project file 'StyleCopTestHarness.csproj'.
d:\Projects\stylecop_249eed5b15ed\Project.AutoFix\Test\Harnesses\TestHarness\StyleCopTestHarness.csproj(117,3): The imported project "d:\Tools\msbuild\StyleCop.Build.Targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

d:\Projects\stylecop_249eed5b15ed\Project.AutoFix\Src\SettingsEditor\SettingsEditor.csproj : error : Unable to read the project file 'SettingsEditor.csproj'.
d:\Projects\stylecop_249eed5b15ed\Project.AutoFix\Src\SettingsEditor\SettingsEditor.csproj(123,3): The imported project "d:\Tools\msbuild\StyleCop.Build.Targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

d:\Projects\stylecop_249eed5b15ed\Project.AutoFix\Src\AddIns\CSharp\CodeModel\CSharpCodeModel.csproj : error : Unable to read the project file 'CSharpCodeModel.csproj'.
d:\Projects\stylecop_249eed5b15ed\Project.AutoFix\Src\AddIns\CSharp\CodeModel\CSharpCodeModel.csproj(470,3): The imported project "d:\Tools\msbuild\StyleCop.Build.Targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

d:\Projects\stylecop_249eed5b15ed\Project.AutoFix\Src\AddIns\CSharp\Analyzers\CSharpAnalyzers.csproj : error : Unable to read the project file 'CSharpAnalyzers.csproj'.
d:\Projects\stylecop_249eed5b15ed\Project.AutoFix\Src\AddIns\CSharp\Analyzers\CSharpAnalyzers.csproj(206,3): The imported project "d:\Tools\msbuild\StyleCop.Build.Targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

d:\Projects\stylecop_249eed5b15ed\Project.AutoFix\Src\AddIns\CSharp\Parser\CSharpParser.csproj : error : Unable to read the project file 'CSharpParser.csproj'.
d:\Projects\stylecop_249eed5b15ed\Project.AutoFix\Src\AddIns\CSharp\Parser\CSharpParser.csproj(80,3): The imported project "d:\Tools\msbuild\StyleCop.Build.Targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

d:\Projects\stylecop_249eed5b15ed\Project.AutoFix\Test\Harnesses\TestHarness\DLL\StyleCopTest.csproj : error : Unable to read the project file 'StyleCopTest.csproj'.
d:\Projects\stylecop_249eed5b15ed\Project.AutoFix\Test\Harnesses\TestHarness\DLL\StyleCopTest.csproj(75,3): The imported project "d:\Tools\msbuild\StyleCop.Build.Targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

What can I do to fix this?
Feb 22, 2014 at 6:55 PM
This is documented in HOWTO: Set up your dev box to build StyleCop

Basically, you have to run Environment.cmd in an elevated command prompt to set up the required development environment variables.

There's a work item to remove dependencies on Environment.cmd here.