我正在尝试通过命令行构建 Visual Studio 扩展包,但遇到了问题。
该项目在 Visual Studio 环境中完美构建,包括发布和调试。我只是想让该项目也能通过命令行构建。其他项目(非 Visual Studio 扩展包项目)都可以正常构建。问题出现在 VSSDK 的引入上。
错误信息:
12:33:41.147 2>C:\Program Files (x86)\MSBuild\Microsoft VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.Common.targets(107,5): error VSSDK1000: Failed to load 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VSSDK\VisualStudioIntegration\Tools\bin\VSCT.exe' Assembly. Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft Visual Studio 12.0\VSSDK\VisualStudioIntegration\Tools\bin\VSCT.exe' or one of its dependencies. An attempt was made to load a program with an incorrect format. [C:\VsProjects\MyProject\MyProject.csproj]
Done executing task "VSCTCompiler" -- FAILED. (TaskId:24)
12:33:41.147 2>Done building target "VSCTCompile" in project "MyProject.csproj" -- FAILED.: (TargetId:42)
12:33:41.147 2>Target "_CheckForCompileOutputs: (TargetId:43)" in file "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\VsProjects\MyProject\MyProject.csproj" (target "_CleanGetCurrentAndPriorFileWrites" depends on it):
我看到了这些文章,其中第一个对我帮助最大,并让我克服了之前的错误,进入了这个错误:
我将VSSDKInstall路径设置为:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VSSDK
我的系统:Windows 8.1 Pro X64
构建:任何CPU
我意识到根据我所读的,该项目是在32位环境下构建的。
我已经实施了以下措施:
- 设置VSSDKInstall环境变量并重新启动
- 执行:call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\vsvars32.bat"
- 进行ms build调用
我运行了诊断构建,这里是一个较大的片段:
12:33:41.132 2>Done building target "PrepareRdlFiles" in project "MyProject.csproj".: (TargetId:39)
Target "RunRdlCompiler" skipped, due to false condition; ('@(RdlFile)'!='') was evaluated as (''!='').
12:33:41.133 2>Target "CompileRdlFiles: (TargetId:40)" in file "C:\Program Files (x86)\MSBuild\Microsoft VisualStudio\v12.0\ReportingServices\Microsoft.ReportingServices.targets" from project "C:\VsProjects\MyProject\MyProject.csproj" (target "PrepareResources" depends on it):
12:33:41.133 2>Done building target "CompileRdlFiles" in project "MyProject.csproj".: (TargetId:40)
12:33:41.133 2>Target "GenerateListOfCTO: (TargetId:41)" in file "C:\Program Files (x86)\MSBuild\Microsoft VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.targets" from project "C:\VsProjects\MyProject\MyProject.csproj" (target "MergeCtoResource" depends on it):
Task "AssignCulture" (TaskId:23)
Task Parameter:
Files=
obj\Debug\MyProject.cto
ResourceName=Menus.ctmenu (TaskId:23)
Culture of "" was assigned to file "obj\Debug\MyProject.cto". (TaskId:23)
Done executing task "AssignCulture". (TaskId:23)
12:33:41.133 2>Done building target "GenerateListOfCTO" in project "MyProject.csproj".: (TargetId:41)
Target "FindSDKInstallation" skipped, due to false condition; ('$(VsSDKInstall)'=='') was evaluated as ('C:\Program Files (x86)\Microsoft Visual Studio 12.0\VSSDK'=='').
12:33:41.133 2>Target "VSCTCompile: (TargetId:42)" in file "C:\Program Files (x86)\MSBuild\Microsoft VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.Common.targets" from project "C:\VsProjects\MyProject\MyProject.csproj" (target "MergeCtoResource" depends on it):
Using "VSCTCompiler" task from assembly "C:\Program Files (x86)\MSBuild\Microsoft VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.Build.Tasks.dll".
Task "VSCTCompiler" (TaskId:24)
Task Parameter:IntermediateDirectory=obj\Debug\ (TaskId:24)
Task Parameter:
Definitions=
__CTC__
_CTC_GUIDS_ (TaskId:24)
Task Parameter:NoLogo=True (TaskId:24)
Task Parameter:OutputFile=MyProject.cto (TaskId:24)
Task Parameter:Source=MyProject.vsct (TaskId:24)
Task Parameter:Verbose=False (TaskId:24)
Task Parameter:SDKVersion=12.0 (TaskId:24)
12:33:41.147 2>C:\Program Files (x86)\MSBuild\Microsoft VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.Common.targets(107,5): error VSSDK1000: Failed to load 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VSSDK\VisualStudioIntegration\Tools\bin\VSCT.exe' Assembly. Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft Visual Studio 12.0\VSSDK\VisualStudioIntegration\Tools\bin\VSCT.exe' or one of its dependencies. An attempt was made to load a program with an incorrect format. [C:\VsProjects\MyProject\MyProject.csproj]
Done executing task "VSCTCompiler" -- FAILED. (TaskId:24)
12:33:41.147 2>Done building target "VSCTCompile" in project "MyProject.csproj" -- FAILED.: (TargetId:42)
12:33:41.147 2>Target "_CheckForCompileOutputs: (TargetId:43)" in file "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\VsProjects\MyProject\MyProject.csproj" (target "_CleanGetCurrentAndPriorFileWrites" depends on it):
12:33:41.148 2>Done building target "_CheckForCompileOutputs" in project "MyProject.csproj".: (TargetId:43)
Target "_SGenCheckForOutputs" skipped, due to false condition; ('$(_SGenGenerateSerializationAssembliesConfig)' == 'On' or ('@(WebReferenceUrl)'!='' and '$(_SGenGenerateSerializationAssembliesConfig)' == 'Auto')) was evaluated as ('Off' == 'On' or (''!='' and 'Off' == 'Auto')).
12:33:41.148 2>Target "_CleanGetCurrentAndPriorFileWrites: (TargetId:44)" in file "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\VsProjects\MyProject\MyProject.csproj" (target "_CleanRecordFileWrites" depends on it):
这是正常的输出:
1/4/2015 1:10:05 PM: Building project step 11 - Build: Debug (Any CPU)...
Pre-processing...
Building configuration 'Debug|Any CPU'...
Microsoft (R) Build Engine version 12.0.31101.0
[Microsoft .NET Framework, version 4.0.30319.34014]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 1/4/2015 1:10:06 PM.
1>Project "C:\VsProjects\MyProject.sln" on node 1 (default targets).
1>ValidateSolutionConfiguration:
Building solution configuration "Debug|Any CPU".
1>Project "C:\VsProjects\MyProject.sln" (1) is building "C:\VsProjects\MyProject\MyProject.csproj" (2) on node 1 (default targets).
2>MainResourcesGeneration:
Skipping target "MainResourcesGeneration" because all output files are up-to-date with respect to the input files.
CoreResGen:
No resources are out of date with respect to their source files. Skipping resource generation.
2>C:\Program Files (x86)\MSBuild\Microsoft VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.Common.targets(107,5): error VSSDK1000: Failed to load 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VSSDK\VisualStudioIntegration\Tools\bin\VSCT.exe' Assembly. Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft Visual Studio 12.0\VSSDK\VisualStudioIntegration\Tools\bin\VSCT.exe' or one of its dependencies. An attempt was made to load a program with an incorrect format. [C:\VsProjects\MyProject\MyProject.csproj]
2>Done Building Project "C:\VsProjects\MyProject\MyProject.csproj" (default targets) -- FAILED.
1>Done Building Project "C:\VsProjects\MyProject.sln" (default targets) -- FAILED.
Build FAILED.
"C:\VsProjects\MyProject.sln" (default target) (1) ->
"C:\VsProjects\MyProject\MyProject.csproj" (default target) (2) ->
(VSCTCompile target) ->
C:\Program Files (x86)\MSBuild\Microsoft VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.Common.targets(107,5): error VSSDK1000: Failed to load 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VSSDK\VisualStudioIntegration\Tools\bin\VSCT.exe' Assembly. Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft Visual Studio 12.0\VSSDK\VisualStudioIntegration\Tools\bin\VSCT.exe' or one of its dependencies. An attempt was made to load a program with an incorrect format. [C:\VsProjects\MyProject\MyProject.csproj]
更新:
- 问题可能出在我设置的VSSDKInstall环境变量上,因为我尝试在VS内部构建项目时失败了,无论是调试还是发布。我不得不删除环境变量并重新启动计算机。
更新:2015年1月29日
完整路径如下:
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\msbuild.exe
我使用一个构建工具,它调用一个脚本。
以下是来自诊断msbuild的摘录。我删除了无关的部分。
Building configuration 'Debug|Any CPU'...
Microsoft (R) Build Engine version 12.0.31101.0
[Microsoft .NET Framework, version 4.0.30319.18444]
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\msbuild.exe /maxcpucount:1 /p:Platform=Any CPU /v:diagnostic <path to project>\myproject.sln
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 1/29/2015 8:04:26 AM.
Environment at start of build:
ALLUSERSPROFILE = C:\ProgramData
ANT_HOME = C:\SoftDev\Tools\Java\Ant\apache-ant-1.9.3
APPDATA = C:\Users\sarahmarci.JMR\AppData\Roaming
ArmServerInfo = 02272370
asl.log = Destination=file
Done building target "ResGen" in project "myproject.csproj".: (TargetId:37)
Target "CompileLicxFiles" skipped, due to false condition; ('@(_LicxFile)'!='') was evaluated as (''!='').
Target "PrepareRdlFiles: (TargetId:38)" in file "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\ReportingServices\Microsoft.ReportingServices.targets" from project "<path to project>\<my project>\myproject.csproj" (target "CompileRdlFiles" depends on it):
Task "CreateItem" skipped, due to false condition; ('%(Extension)'=='.rdlc') was evaluated as ('.resx'=='.rdlc').
Task "CreateItem" skipped, due to false condition; ('%(Extension)'=='.rdlc') was evaluated as ('.ico'=='.rdlc').
Task "CreateItem" skipped, due to false condition; ('%(Extension)'=='.rdlc') was evaluated as ('.png'=='.rdlc').
Task "CreateItem" skipped, due to false condition; ('%(Extension)'=='.rdlc') was evaluated as ('.rtf'=='.rdlc').
Task "CreateItem" skipped, due to false condition; ('%(Extension)'=='.rdlc') was evaluated as ('.docx'=='.rdlc').
Task "CreateItem" skipped, due to false condition; ('%(Extension)'=='.rdlc') was evaluated as ('.txt'=='.rdlc').
Done building target "PrepareRdlFiles" in project "myproject.csproj".: (TargetId:38)
Target "RunRdlCompiler" skipped, due to false condition; ('@(RdlFile)'!='') was evaluated as (''!='').
Target "CompileRdlFiles: (TargetId:39)" in file "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\ReportingServices\Microsoft.ReportingServices.targets" from project "<path to project>\<my project>\myproject.csproj" (target "PrepareResources" depends on it):
Done building target "CompileRdlFiles" in project "myproject.csproj".: (TargetId:39)
Target "GenerateListOfCTO: (TargetId:40)" in file "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.targets" from project "<path to project>\<my project>\myproject.csproj" (target "MergeCtoResource" depends on it):
Task "AssignCulture" (TaskId:22)
Task Parameter:
Files=
obj\Debug\myproject.cto
ResourceName=Menus.ctmenu (TaskId:22)
Culture of "" was assigned to file "obj\Debug\myproject.cto". (TaskId:22)
Done executing task "AssignCulture". (TaskId:22)
Done building target "GenerateListOfCTO" in project "myproject.csproj".: (TargetId:40)
Target "FindSDKInstallation: (TargetId:41)" in file "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.Common.targets" from project "<path to project>\<my project>\myproject.csproj" (target "VSCTCompile" depends on it):
Using "FindVsSDKInstallation" task from assembly "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.Build.Tasks.dll".
Task "FindVsSDKInstallation" (TaskId:23)
Task Parameter:SDKVersion=12.0 (TaskId:23)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.Common.targets(74,5): error VSSDK1036: Can not find the installation for VS SDK. [<path to project>\<my project>\myproject.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.Common.targets(76,7): error MSB4018: The "FindVsSDKInstallation" task failed unexpectedly. [<path to project>\<my project>\myproject.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.Common.targets(76,7): error MSB4018: System.ArgumentNullException: Value cannot be null. [<path to project>\<my project>\myproject.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.Common.targets(76,7): error MSB4018: Parameter name: path1 [<path to project>\<my project>\myproject.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.Common.targets(76,7): error MSB4018: at System.IO.Path.Combine(String path1, String path2) [<path to project>\<my project>\myproject.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.Common.targets(76,7): error MSB4028: The "FindVsSDKInstallation" task's outputs could not be retrieved from the "IncludesPath" parameter. Value cannot be null. [<path to project>\<my project>\myproject.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.Common.targets(76,7): error MSB4028: Parameter name: path1 [<path to project>\<my project>\myproject.csproj]
Done executing task "FindVsSDKInstallation" -- FAILED. (TaskId:23)
您有什么想法?