3

I am trying to build a Visual Studio Package from the command line and running into problems.

The project builds perfectly inside the Visual Studio environment, both release and debug. I am just trying to get the project to build through command line as well. Other projects, not Visual Studio Package projects, build fine. The problem is the introduction of the VSSDK.

Error:

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):

I did see these articles, the first of which helped the most and got me past the previous error and onto this error:

MS Build with VS2012 Package Project

MS Build command line...VSSDK

Build a VS Package in Team Environment

I set the VSSDKInstall path to:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VSSDK

My system: Windows 8.1 Pro X64

Build: Any CPU

I do realize that the project builds in 32-bit environment from what I have read.

I did implement:

  1. Set VSSDKInstall environment variable and restart
  2. Execute: call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\vsvars32.bat"
  3. Do the ms build call

I ran the diagnostic build and here is a larger fragment:

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):

Here is the normal output:

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]

UPDATE:

  1. The problem might be what I set the VSSDKInstall environment variable to, because I tried to build the project inside VS and failed, both in debug and release. I was forced to remove the environment variable and restart the computer.

UPDATE: January 29, 2015

Full path is:

C:\Program Files (x86)\MSBuild\12.0\bin\amd64\msbuild.exe

I use a build utility, which calls a script.

Here is an excerpt from the diagnostic msbuild. I cut out extraneous things.

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)

Thoughts?

Community
  • 1
  • 1
Sarah Weinberger
  • 15,041
  • 25
  • 83
  • 130
  • I have edited your title. Please see, "[Should questions include “tags” in their titles?](http://meta.stackexchange.com/questions/19190/)", where the consensus is "no, they should not". – John Saunders Jan 04 '15 at 21:20
  • @JohnSaunders - the SDK is not in the tags. Maybe it's implied by vspackage but I still think you should have left it alone. – H H Jan 04 '15 at 21:25
  • @JohnSaunders I did not realize that tags are not allowed in the title, so I will keep that in mind. Thank you, however VSSDK, which used to be in the title, is not one of my tags. I added VSSDK in the title, because there was no tag for VSSDK. Henk Holterman said the same thing as me. Personally, I do not think that VSSDK is implied by VS Package. VS Packages require the VSSDK. One can debate if VSSDK and Packages are one and the same, but that is beyond the scope of this question. – Sarah Weinberger Jan 04 '15 at 21:26
  • @HenkHolterman: I added [tag:visual-studio-sdk]. – John Saunders Jan 04 '15 at 21:27

1 Answers1

11

I had faced similar problem and here's how I solved it.

Few facts before that:

1) VSCT.exe is a 32-bit exe. That's the only version which is shipped. You can confirm that by locating the exe listed in the error message and running "dumpbin /headers vsct.exe" and see that it's a x86 (or 32-bit) binary.

2) A 64-bit exe/dll cannot load a 32-bit binary. And if tried gives this "incorrect format" exception which you are seeing in your exception details.

3) MSBuild.exe ships as both 64-bit and 32-bit binaries.

Answer: This error will happen if you use 64-bit MSBuild.exe to compile any project containing VSCTCompile target. The reason is VSCT.exe is a 32-bit exe and you are trying to call that from 64-bit msbuild.exe.

Fix: To fix this, you should either explicitly use 32-bit msbuild.exe or open a 32-bit command line. Here's how you do that: http://www.tipandtrick.net/how-to-open-and-run-32-bit-command-prompt-in-64-bit-x64-windows/

If you run msbuild from 32-bit command line window then your build should succeed.

user862268
  • 456
  • 1
  • 4
  • 7
  • I believe that I am using a 32-bit version of build, see my update above. Complete path is "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\msbuild.exe". – Sarah Weinberger Jan 29 '15 at 16:13
  • 1
    Look at amd64 in your path. You are using 64-bit binary. It's wierd that microsoft decided to put 64-bit binary under Program Files(x86), but that's what it is. Use the path: C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe. – user862268 Jan 30 '15 at 16:40