VSCT.exe 无法加载文件或程序集
本文关键字:文件 程序集 加载 exe VSCT | 更新日期: 2023-09-27 18:36:14
我正在尝试从命令行构建Visual Studio Package并遇到问题。
该项目在Visual Studio环境中完美构建,无论是发布还是调试。我只是想让项目也通过命令行构建。其他项目,不是Visual Studio Package项目,构建良好。问题是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):
我确实看到了这些文章,其中第一篇帮助最大,让我克服了以前的错误并进入了这个错误:
MS 构建与 VS2012 包项目
MS 构建命令行...VSSDK
在团队环境中生成 VS 包
我将 VSSDKInstall 路径设置为:
C:'Program Files (x86)'Microsoft Visual Studio 12.0'VSSDK
我的系统: 视窗 8.1 专业版 X64
构建:任何中央处理器
我确实意识到该项目在我所阅读的 32 位环境中构建。
我确实实现了:
- 设置 VSSDKInstall 环境变量并重新启动
- 执行:调用"C:''Program Files (x86)''Microsoft Visual Studio 12.0''Common7''Tools''vsvars32.bat"
- 执行毫秒构建调用
我运行了诊断版本,这是一个更大的片段:
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)
思潮?
我遇到了类似的问题,这是我如何解决的。
在此之前的几个事实:
1) VSCT.exe 是一个 32 位的 exe。这是唯一发布的版本。您可以通过找到错误消息中列出的 exe 并运行"dumpbin/headers vsct.exe"来确认这一点,并查看它是一个 x86(或 32 位)二进制文件。
2) 64 位 exe/dll 无法加载 32 位二进制文件。如果尝试,则会给出您在异常详细信息中看到的"格式不正确"异常。
3) MSBuild.exe 以 64 位和 32 位二进制文件的形式提供。
答:如果使用 64 位 MSBuild.exe编译包含 VSCTCompile 目标的任何项目,则会发生此错误。原因是 VSCT.exe 是一个 32 位 exe,您正在尝试从 64 位 msbuild.exe 调用它。
修复:若要解决此问题,应显式使用 32 位 msbuild.exe或打开 32 位命令行。以下是您执行此操作的方法: http://www.tipandtrick.net/how-to-open-and-run-32-bit-command-prompt-in-64-bit-x64-windows/
如果从 32 位命令行窗口运行 msbuild,则生成应该会成功。