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:
Set VSSDKInstall environment variable and restart
Execute: call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\vsvars32.bat"
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:
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?
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.
Related
I have been trying to build a .NET project with visual studio 2017 Community on my local.
The build works fine when done using Publish option but throws below error when trying using msbuild
C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API>msbuild
Microsoft (R) Build Engine version 4.8.4084.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 2021-06-28 3:55:47 PM.
Project "C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj" on node 1 (default targets).
C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj(281,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualSt
udio\**v11.0**\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Done Building Project "C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj" (default targets) -- FAILED.
Build FAILED.
"C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj" (default target) (1) ->
C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj(281,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\Visual
Studio\**v11.0**\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on
disk.
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.08
I have gone through various similar articles on Stackoverflow and various other sites but none of them help.
Where it is pulling v11.0 from? I don't have that value in my csproj file.
Are you using correct version of MSBuild?
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
C:\Windows\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\MSBuild.exe
The path to MSBuild could be different depending on your pc
If Yes check the following example
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj /t:Clean
For more information run the following command:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /?
You can also use this link
I cleaned up my system and reinstalled msbuild and it works fine now.
I am getting below error while building jenkins build for a .net project.
C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet\FleetPride.Timesheet.csproj(440,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
As It's trying to find the Visual studio folder on the server which is not present on the server. So is it mandatory to have the visual studio installed on the server?
Below is the complete error log I am getting in jenkins.
Building in workspace C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT
C:\Program Files\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
C:\Program Files\Git\bin\git.exe config remote.origin.url https://bitbucket.org/pure-nmittal/timesheet/src/master/ # timeout=10
Fetching upstream changes from https://bitbucket.org/pure-nmittal/timesheet/src/master/
C:\Program Files\Git\bin\git.exe --version # timeout=10
using GIT_ASKPASS to set credentials
C:\Program Files\Git\bin\git.exe fetch --tags --progress https://bitbucket.org/pure-nmittal/timesheet/src/master/ +refs/heads/*:refs/remotes/origin/*
C:\Program Files\Git\bin\git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
C:\Program Files\Git\bin\git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision 25e45ba269d04cb48a4d17090e391df08f73bedf (refs/remotes/origin/master)
C:\Program Files\Git\bin\git.exe config core.sparsecheckout # timeout=10
C:\Program Files\Git\bin\git.exe checkout -f 25e45ba269d04cb48a4d17090e391df08f73bedf
Commit message: "profile"
C:\Program Files\Git\bin\git.exe rev-list --no-walk 25e45ba269d04cb48a4d17090e391df08f73bedf # timeout=10
[Timesheet_UAT] $ powershell.exe -NonInteractive -ExecutionPolicy ByPass "& 'C:\Windows\TEMP\jenkins2437051443515371203.ps1'"
--Restoring Nuget packages BEGIN--
MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin\amd64'.
All packages listed in packages.config are already installed.
--Restoring Nuget packages END--
Path To MSBuild.exe: C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe
Executing the command cmd.exe /C " chcp 1252 & "C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe" /p:DeployOnBuild=true /p:PublishProfile=UAT "C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet.sln" " && exit %%ERRORLEVEL%% from C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT
[Timesheet_UAT] $ cmd.exe /C " chcp 1252 & "C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe" /p:DeployOnBuild=true /p:PublishProfile=UAT "C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet.sln" " && exit %%ERRORLEVEL%%
Active code page: 1252
Microsoft (R) Build Engine version 14.0.23107.0
Copyright (C) Microsoft Corporation. All rights reserved.
-
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 11/27/2018 1:30:20 AM.
Project "C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "Debug|Any CPU".
Project "C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet.sln" (1) is building "C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet\FleetPride.Timesheet.csproj" (2) on node 1 (default targets).
C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet\FleetPride.Timesheet.csproj(440,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Done Building Project "C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet\FleetPride.Timesheet.csproj" (default targets) -- FAILED.
Project "C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet.sln" (1) is building "C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet.Tests\FleetPride.Timesheet.Tests.csproj" (3) on node 1 (default targets).
C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1097,5): warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet.Tests\FleetPride.Timesheet.Tests.csproj]
Project "C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet.Tests\FleetPride.Timesheet.Tests.csproj" (3) is building "C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet\FleetPride.Timesheet.csproj" (2:2) on node 1 (default targets).
C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet\FleetPride.Timesheet.csproj(440,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Done Building Project "C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet\FleetPride.Timesheet.csproj" (default targets) -- FAILED.
Done Building Project "C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet.Tests\FleetPride.Timesheet.Tests.csproj" (default targets) -- FAILED.
Done Building Project "C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet.sln" (default targets) -- FAILED.
Build FAILED.
"C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet.sln" (default target) (1) ->
"C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet.Tests\FleetPride.Timesheet.Tests.csproj" (default target) (3) ->
(GetReferenceAssemblyPaths target) ->
C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1097,5): warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet.Tests\FleetPride.Timesheet.Tests.csproj]
"C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet.sln" (default target) (1) ->
"C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet\FleetPride.Timesheet.csproj" (default target) (2) ->
C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet\FleetPride.Timesheet.csproj(440,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
"C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet.sln" (default target) (1) ->
"C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet.Tests\FleetPride.Timesheet.Tests.csproj" (default target) (3) ->
"C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet\FleetPride.Timesheet.csproj" (default target) (2:2) ->
C:\Program Files (x86)\Jenkins\workspace\Timesheet_UAT\FleetPride.Timesheet\FleetPride.Timesheet\FleetPride.Timesheet.csproj(440,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
1 Warning(s)
2 Error(s)
Time Elapsed 00:00:00.21
Build step 'Build a Visual Studio project or solution using MSBuild' marked build as failure
Finished: FAILURE
I am having problems getting my pipeline to succeed.
Obviously the sources are identical (just cloned from master).
The strange thing is when I run the same command using cmd it works.
What is happening ?
I am using .NET 4.6.1
cmd:
C:\Windows\System32>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe"
"C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\Libs.sln" /p:Configuration=Release
[...]
Build succeeded.
0 Warning(s)
0 Error(s)
gitlab CI:
Running with gitlab-runner 11.2.0 (35e8515d)
on .NET BUILDER 67dcb956
Using Shell executor...
Running on <computername>...
Cloning repository...
Cloning into 'C:/temp/GitLabRunner/builds/67dcb956/0/<companyname>/libs'...
Checking out 776042ef as master...
Skipping Git submodules setup
$ & "$env:NUGET_PATH" restore
MSBuild auto-detection: using msbuild version '15.8.166.59604' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin'.
Restoring NuGet package Newtonsoft.Json.11.0.2.
Adding package 'Newtonsoft.Json.11.0.2' to folder 'C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\packages'
Added package 'Newtonsoft.Json.11.0.2' to folder 'C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\packages'
NuGet Config files used:
C:\WINDOWS\system32\config\systemprofile\AppData\Roaming\NuGet\NuGet.Config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
Feeds used:
C:\WINDOWS\system32\config\systemprofile\.nuget\packages\
https://api.nuget.org/v3/index.json
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
Installed:
1 package(s) to packages.config projects
$ & "$env:MSBUILD_PATH" /p:Configuration=Release
Microsoft (R) Build Engine version 14.0.23107.0
Copyright (C) Microsoft Corporation. All rights reserved.
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 23/08/2018 14:08:49.
Project "C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\Libs.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "Release|Any CPU".
Project "C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\Libs.sln" (1) is building "C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\Tools\Tools.csproj" (2) on node 1 (default targets).
PrepareForBuild:
Creating directory "bin\Release\".
Creating directory "obj\Release\".
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
C:\Program Files (x86)\MSBuild\14.0\bin\csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:TRACE /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\mscorlib.dll" /reference:C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Management.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Runtime.Serialization.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Xml.dll" /debug:pdbonly /filealign:512 /optimize+ /out:obj\Release\Tools.dll /subsystemversion:6.00 /target:library /utf8output Attributes\EncryptedElementAttribute.cs Config\ConfigBase.cs Config\ConfigManager.cs Config\IConfig.cs Config\SerializationOption.cs Cryptography\CryptoHelper.cs CustomObjects\EncodingStringWriter.cs ExitCodes.cs ExtensionMethods.cs Globalization\GlobalizationTools.cs http\HttpHelper.cs IO\FileOutputHelper.cs IO\IOHelper.cs Licensing\Base32Converter.cs Licensing\Enrypt.cs Licensing\LicenseManager.cs Logging\ILogFile.cs Logging\LogFile.cs Logging\LogLevel.cs Logging\NotifyingLogFile.cs Networking\NetworkTools.cs Plugins\PluginManager.cs Properties\AssemblyInfo.cs Serialization\CustomXmlSerializer.cs Serialization\JSONSerializer.cs Serialization\XMLSerializer.cs Smtp\SmtpConfig.cs Tools.cs "C:\WINDOWS\TEMP\.NETFramework,Version=v4.6.1.AssemblyAttributes.cs"
ExtensionMethods.cs(109,45): error CS1525: Invalid expression term 'int' [C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\Tools\Tools.csproj]
ExtensionMethods.cs(109,49): error CS1003: Syntax error, ',' expected [C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\Tools\Tools.csproj]
Done Building Project "C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\Tools\Tools.csproj" (default targets) -- FAILED.
Project "C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\Libs.sln" (1) is building "C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\UITools\UITools.csproj" (3) on node 1 (default targets).
PrepareForBuild:
Creating directory "bin\Release\".
Creating directory "obj\Release\".
Done Building Project "C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\UITools\UITools.csproj" (default targets) -- FAILED.
Project "C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\Libs.sln" (1) is building "C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\DBTools\DBTools.csproj" (4) on node 1 (default targets).
PrepareForBuild:
Creating directory "bin\Release\".
Creating directory "obj\Release\".
Done Building Project "C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\DBTools\DBTools.csproj" (default targets) -- FAILED.
Project "C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\Libs.sln" (1) is building "C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\UIToolsWPF\UIToolsWPF.csproj" (5) on node 1 (default targets).
PrepareForBuild:
Creating directory "bin\Release\".
Creating directory "obj\Release\".
Done Building Project "C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\UIToolsWPF\UIToolsWPF.csproj" (default targets) -- FAILED.
Done Building Project "C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\Libs.sln" (default targets) -- FAILED.
Build FAILED.
"C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\Libs.sln" (default target) (1) ->
"C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\Tools\Tools.csproj" (default target) (2) ->
(CoreCompile target) ->
ExtensionMethods.cs(109,45): error CS1525: Invalid expression term 'int' [C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\Tools\Tools.csproj]
ExtensionMethods.cs(109,49): error CS1003: Syntax error, ',' expected [C:\temp\GitLabRunner\builds\67dcb956\0\<companyname>\libs\Tools\Tools.csproj]
0 Warning(s)
2 Error(s)
Time Elapsed 00:00:00.92
This is the code that causes failure:
if (int.TryParse(s, out int mins))
{
return TimeSpan.FromMinutes(mins);
}
So thanks to mjwills I checked again my .gitlab-ci.yml.
It turned out I had the following line in it:
MSBUILD_PATH: 'C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe'
Basically I had a mismatch in MSBuild-Versions while logs were sayin I was using Version 15.
Changing it to:
`MSBUILD_PATH: 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe'`
resolved the issue.
I am doing automation using selenium and c#. Everything is running file when I run from visual studio but getting issue in file path then run via jenkins.
Batch command I am trying :
"nuget.exe" restore UnitTestProject1.sln
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe" UnitTestProject1.sln
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\MSTest.exe" /testcontainer:UnitTestProject1\bin\Debug\UnitTestProject1.dll
Output from Jenkins :
Building in workspace C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1
[UnitTestProject1] $ cmd /c call C:\Users\developer\AppData\Local\Temp\jenkins934555759751738078.bat
C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1>"nuget.exe" restore UnitTestProject1.sln
MSBuild auto-detection: using msbuild version '15.5.180.51428' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\bin'.
All packages listed in packages.config are already installed.
C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1>"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe" UnitTestProject1.sln
Microsoft (R) Build Engine version 4.6.1055.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 3/5/2018 6:38:36 PM.
Project "C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1\UnitTestProject1.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "Debug|Any CPU".
Project "C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1\UnitTestProject1.sln" (1) is building "C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1\UnitTestProject1\UnitTestProject1.csproj" (2) on node 1 (default targets).
Project file contains ToolsVersion="15.0". This toolset may be unknown or missing, in which case you may be able to resolve this by installing the appropriate version of MSBuild, or the build may have been forced to a particular ToolsVersion for policy reasons. Treating the project as if it had ToolsVersion="4.0". For more information, please see http://go.microsoft.com/fwlink/?LinkId=291333.
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
_CopyOutOfDateSourceItemsToOutputDirectory:
Skipping target "_CopyOutOfDateSourceItemsToOutputDirectory" because all output files are up-to-date with respect to the input files.
_CopyAppConfigFile:
Skipping target "_CopyAppConfigFile" because all output files are up-to-date with respect to the input files.
CopyFilesToOutputDirectory:
UnitTestProject1 -> C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1\UnitTestProject1\bin\Debug\UnitTestProject1.dll
Done Building Project "C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1\UnitTestProject1\UnitTestProject1.csproj" (default targets).
Done Building Project "C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1\UnitTestProject1.sln" (default targets).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.03
C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\MSTest.exe"
Microsoft (R) Test Execution Command Line Tool Version 15.0.27019.1
Copyright (c) Microsoft Corporation. All rights reserved.
Please specify tests to run, or specify the /publish switch to publish results.
For switch syntax, type "MSTest /help"
C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1>/testcontainer:UnitTestProject1.dll
The filename, directory name, or volume label syntax is incorrect.
C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1>exit 123
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
It seems everything is fine till end. It has issue in finding project dll file at end with test container.
I have the following set as a Windows Batch command:
. This is one long line that runs the individual project Test DLLs of our components. Each DLL is from a Unit Test Project.
It appears that your command line has forward slashes, and not the Windows directory separator, the backslash.
I have also found that I needed a different command line to get my tests running properly. I had to use the vstest.console.exe to run the tests.
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" Application_Tests\bin\Release\Application_Tests.dll AppLib_Tests\bin\Release\AppLib_Tests.dll
For the full command line: vstest.console.exe command line
I am using Visual Studio 2017 and I want to add a post-build command. when I go to 'Macros' window I see the correct path coresponging to $(ProjectDir) variable. So I added the command:
$(ProjectDir)ClientApp\npm run build
but when I execute build I get the following error:
The command 'ClientApp\npm run build'exited with code 3.
I change MSBuild verbose to Diagnose and in the Output window I saw:
1>Target "PostBuildEvent" in file "C:\Program Files (x86)\Microsoft
Visual
Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets":
1> Using "Exec" task from assembly "Microsoft.Build.Tasks.Core,
Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1> Task "Exec" 1> Task
Parameter:WorkingDirectory=bin\Debug\netcoreapp1.1\ 1> Task
Parameter:Command=ClientApp\npm run build 1> ClientApp\npm run
build 1> The system cannot find the path specified. 1>
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(4933,5):
error MSB3073: The command "ClientApp\npm run build" exited with code
3. 1> Done executing task "Exec" -- FAILED.
In the targets file I got these lines:
<Target
Name="PostBuildEvent"
Condition="'$(PostBuildEvent)' != '' and ('$(RunPostBuildEvent)' != 'OnOutputUpdated' or '$(_AssemblyTimestampBeforeCompile)' != '$(_AssemblyTimestampAfterCompile)')"
DependsOnTargets="$(PostBuildEventDependsOn)">
<Exec WorkingDirectory="$(OutDir)" Command="$(PostBuildEvent)" />
</Target>
Can I change the working dir from $(OutDir) to $(ProjectDir) and how?
Any ideas where I am mistaken?
NB - I added the command in a BAT file, just to test but the result was the same
Try $(MSBuildProjectDirectory) instead
The problem could affect other VS variable as well.
The universal solution is described here.