I am using devenv command line switches to build and deploy a project. Build is getting started and the project is never deployed. I am using the following line of code
devenv "%pathtosolution%" /deploy Debug /project "%relativepathtoprojectfile%" /projectconfig "Debug|x64"
This is what I am seeing after that
1>------ Build started: Project: %projectname%, Configuration: Debug x64 ------
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE>
Am I missing any switch/argument?
Try %pathtosolution% in place of %pathtosolution and %relativepathtoprojectfile% in place of %relativepathtoprojectfile
in Winbatch, variables are accessed using %var%, not %var
Related
I am trying to build a dotnet 3.5 project solution file with VS Build tools 2017 in Jenkins. The project is compiling well with DotNet 3.5's MSBuild, but when I try the same activity with MSBuild Engine Version 15.9.21+g9802d43bc3, it is throwing MSBUILD : error MSB4025: The project file could not be loaded. Root element is missing.
This is the command which I have used to compile dotnet 3.5 project.
cd "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
MSBuild.exe "%WORKSPACE%\WBR.sln" /p:Configuration=Debug /p:DeployOnBuild=True /p:AllowUntrustedCertificate=True /p:CreatePackageOnPublish=True
Please find below Jenkins execution logs
C:\Users\Netadmin\.jenkins\jobs\FCRS\jobs\FCRS_VS\workspace>cd "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin>MSBuild.exe "C:\Users\Netadmin\.jenkins\jobs\FCRS\jobs\FCRS_VS\workspace\WBR.sln" /p:Configuration=Debug /p:DeployOnBuild=True /p:AllowUntrustedCertificate=True /p:CreatePackageOnPublish=True
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
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 8/19/2019 6:38:12 PM.
MSBUILD : error MSB4025: The project file could not be loaded. Root element is missing.
Build FAILED.
MSBUILD : error MSB4025: The project file could not be loaded. Root element is missing.
0 Warning(s)
1 Error(s)
The below pic is my jenkins workspace directory.
Any help would be great.
When you use command msbuild xx.sln, you are actually build the projects belonging to the solution.
According to your error message: One of the project's project file (xx.csproj) is not loaded cause the msbuild can't read the xml content well. You can try:
1.Open the xx.csproj file and make sure its format is:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
...
</Project>
2.Save it with UTF-8 encoding to avoid BOM be messed up
3.Backup and then delete the .suo and .csproj.user files
4.Otherwise, since it's a asp.net mvc project, you can create a same-name asp.net mvc project by vs2017, copy all the source files to the new project to migrate the project to VS2017
5.Make sure your build tools package install the web development workload:
6.Since it works well when using msbuild from .net3.5, you can install the .net framework 3.5 in your server and try calling the msbuild from C:\Windows\Microsoft.NET\Framework64\v3.5 instead of C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin when building .net 3.5 projects from vs2010.
I'm setting up a Jenkins job for a Windows 10 application.
I need to compile one of the four projects inside the solution with devenv.com executable because it is a project with .vdproj extension (setup project).
The other projects are built successfully with MSBuild without any problem.
The Jenkins job ends successfully when I'm logged in as root on a Jenkins target node, but, fails when I run the job from Jenkins and I'm not logged in.
Need your help or workaround to solve the issue.
PS: we are using ant as task runner and we have a specific task that start the build process.
EDIT 26/01/2017
I would like to provide you other informations like the error message and one step that I've skipped before.
The error message provides a link to a Microsoft Page and reports a configuration problem.
As solved by this StackOverflow post, I've added a new DWORD registry key under
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0_Config\MSBuild\EnableOutOfProcBuild
Can the problem be that this value can't be readed when the User is'nt logged in ?
EDIT 27/01/2017
I'm going crazy with this issue.
The command devenv /? work fine when i run it locally but wont work when i run it from Jenkins with the same error as before: Microsoft Visual Studio found a configuration problem. To fix it restart as administrator or visit http://go.microsoft.com/fwlink/?LinkId=659046 for further information.
So the devenv.com cannot be executed when i'm not logged in ??
UPDATED 31/01/2017#
Here's my .bat file called from a target by ant build.xml
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat"
#set MSBUILD="C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe"
%MSBUILD% "%cd%\src\AutomatedSetupBuild.proj"
pause
Where the AutomatedSetupBuild.proj is an MSBuild script
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<Target Name="Build">
<PropertyGroup>
<DevEnv>C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.com</DevEnv>
<SolutionFile>$(MSBuildProjectDirectory)\MySolution.sln</SolutionFile>
<ProjectFile>MySetupProject\MySetupProject.vdproj</ProjectFile>
<Configuration>Release</Configuration>
</PropertyGroup>
<Exec
Command=""$(DevEnv)" "$(SolutionFile)" /Rebuild "$(Configuration)" /Project "$(ProjectFile)" /ProjectConfig "$(Configuration)" /Log vs.log /useenv"
ContinueOnError="false"
IgnoreExitCode="false"
WorkingDirectory="$(MSBuildProjectDirectory)" />
</Target>
</Project>
As you can see, I'm loading the environment variable before run devenv.com but i receive the same error.
Do you use a free style job or do you use a Jenkinsfile for a pipeline project? In any case, for devenv.com to work, environment variables have to be set up.
Please go to the Windows start menu and look for something like Visual Studio XX -> Visual Studio Tools -> Developer Command Prompt for VS20XX. Press right mouse bottom and select properties. There look for target. In my case this field contains the following string:
%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat""
If you use e.g. a Jenkinsfile, change the call to devnenv.com, which probably looks like
bat "devenv.com my_solution_file.sln /project my_project /build \"Release|x64\""
to
bat "call \"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat\"; devenv.com my_solution_file.sln /project my_project /build \"Release|x64\""
It is important, that the call to the VsDevCmd.bat is within the same bat command. Otherwise the environment variable settings get lost and are not seen by a second call to bat.
Open the dev command prompt type "where devenv" then call the full path with the .com version... e.g.
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.com" /Rebuild "RELEASE|Win32" "F:\project.sln"
For my part, I had to convert the Visual Studio 2015 SSRS project to SSRS Visual Studio 2017. Then I installed the 2017 SSDT for VS 2017, and use MSBUILD. Everything works well without open remote session.
I have a build server that until recently had up to .Net 4.5.1 and VS2010/VS2012 installed. I ran MSBuild to build and package web apps as follows:
"C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" Hartford.Pace.sln /nologo /v:n /p:Configuration=Release /p:DeployOnBuild=True /p:CreatePackageOnPublish=True /p:AutoParameterizationWebConfigConnectionStrings=False /p:EnableNuGetPackageRestore=True
I recently updated the build server to include Frameworks through 4.6.1 and VS2013/VS2015. Everything was installed in sequence. I updated the build command to:
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" Hartford.Pace.sln /nologo /v:n /p:Configuration=Release /p:DeployOnBuild=True /p:CreatePackageOnPublish=True /p:AutoParameterizationWebConfigConnectionStrings=False /p:EnableNuGetPackageRestore=True /p:VisualStudioVersion=10.0
And now I'm getting the following error only for VS2010 web apps:
"d:\a5\bi_hartsource_pace\Microsoft_Build_Web_App\trunk\Hartford.Pace.sln" (default target) (1) ->
"d:\a5\bi_hartsource_pace\Microsoft_Build_Web_App\trunk\Hartford.Pace.Services\Hartford.Pace.Services.csproj" (default target) (2) ->
(PackageUsingManifest target) ->
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets(3009,5): error : Web deployment task failed. (Unknown ProviderOption:DefiningProjectFullPath. Known ProviderOptions are:.) [d:\a5\bi_hartsource_pace\Microsoft_Build_Web_App\trunk\Hartford.Pace.Services\Hartford.Pace.Services.csproj]
Which points to a problem with the packaging target files. I checked them and none of them were changed by the update.
Does anyone know of side-by-side issues with VS2010 and VS2015? I'd like to upgrade the VS2010 Solutions but it's not my code and I need to build existing apps without modification.
Is this the best method for packaging an app without having the developers create publishing profiles or running anything at their end? This is supposed to be a fully automated build and deploy process. It has been working for three years with no issues but I'm open to suggestions that I can implement entirely on my build server without involving changing files in the source code (including csproj or other controlling files).
Add /p:VisualStudioVersion=10.0
TLDR; devenv appears to build dependencies with whatever config/platform was last selected in the GUI, rather than what /projectconfig says. Ideas?
I have a Visual Studio 2012 solution that builds debug & release, win32 & x64. It has two projects
"common" produces a static library
"foo" produces a dll, and links with common.lib
Both projects output to $(SolutionDir)$(Configuration)_$(Platform), e.g. myTest/Release_Win32 so I can easily swap between configs.
The project foo depends on common, and when I explicitly build foo in the full GUI it properly builds common first, for whichever configuration/platform I'm currently targetting.
However, If I run the command line
devenv.exe myTest/myTest.sln /project foo /projectconfig "Release|x64" /build
Then it will fail because it can't find common.lib when linking. Indeed, there's no myTest/Release_x64/common.lib, but there IS myTest/Debug_Win32/common.lib. I can verify this is caused by that devenv command, it re-appears after removing all the directories.
It appears devenv is trying to build common as a dependency, but failing to specify the projectconfig and falling back to the default Debug & Win32.
I can work around this by manually building common before attempting to build foo, but I'd prefer it to happen automagically. Has anyone else encountered this, or have a workaround/solution?
Here's a solution that demonstrates the problem, and how I created it:
http://beanalby.net/stackExchange/vsDepends.zip
created "common" as Static Lib with new solution
created "foo" as Console App in that solution
added $(OutDir)common.lib as Additional Dependency under Linker/Input for all configurations on foo
marked "foo" depends on "common"
exited visual studio, saving projects & solution
running devenv myTest/myTest.sln /project foo /projectconfig "Release|x64" /build produces:
C:\Users\jason\Desktop>devenv myTest/myTest.sln /project foo /projectconfig "Release|x64" /build
Microsoft (R) Microsoft Visual Studio 2012 Version 11.0.60610.1.
Copyright (C) Microsoft Corp. All rights reserved.
1>------ Build started: Project: common, Configuration: Debug Win32 ------
1>Build started 11/15/2013 13:15:22.
1>PrepareForBuild:
1> Creating directory "C:\Users\jason\Desktop\myTest\Debug\".
1>InitializeBuildStatus:
1> Creating "Debug\common.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>ClCompile:
1> stdafx.cpp
1>Lib:
1> common.vcxproj -> C:\Users\jason\Desktop\myTest\Debug\common.lib
1>FinalizeBuildStatus:
1> Deleting file "Debug\common.unsuccessfulbuild".
1> Touching "Debug\common.lastbuildstate".
1>
1>Build succeeded.
1>
1>Time Elapsed 00:00:00.52
2>------ Build started: Project: foo, Configuration: Release x64 ------
2>Build started 11/15/2013 13:15:22.
2>PrepareForBuild:
2> Creating directory "C:\Users\jason\Desktop\myTest\x64\Release\".
2>InitializeBuildStatus:
2> Creating "x64\Release\foo.unsuccessfulbuild" because "AlwaysCreate" was specified.
2>ClCompile:
2> stdafx.cpp
2> foo.cpp
2>LINK : fatal error LNK1181: cannot open input file 'C:\Users\jason\Desktop\myTest\x64\Release\comm
on.lib'
2>
2>Build FAILED.
2>
2>Time Elapsed 00:00:00.56
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
If you open Visual Studio, change the platform/config to anything else, and exit (it won't ask to save), then common will build as THAT platform/config.
This happens with both the VS2012 x64 Cross Tools Command Prompt and VS2012 x86 Native Tools Command Prompt.
Confirming Hans Passant's comment, The docs for devenv say:
Note
For build-related tasks, it is now recommended that you use MSBuild
instead of devenv. For more information, see MSBuild Command-Line Reference.
Using MSBuild instead as
MSBuild.exe myTest/myTest.sln /t:foo /p:Configuration=Release;Platform=x64
lets it get the platform & config properly. This Q/A shall serve as a warning to those still using devenv on the command line. Repent & switch!
I am copying .exe file form a separate to my main project's folder on prebuild event but I need to build that project before build my main project so i want to build that project on prebuild event of my main project.
Not that this is the best solution, but it will definitely work for what you want to do: Put the below into your pre-build event
"$(VS100COMNTOOLS)..\IDE\devenv" "csproj location OR sln location" /Rebuild "configuration required if you have more than configuration ex: Debug|x64"
This is what worked for me:
"$(DevEnvDir)devenv" "$(SolutionDir)MySolution.sln" /Build $(configuration) /project "$(SolutionDir)MyProjectFolder\MyProject.csproj"
Here $(DevEnvDir), $(SolutionDir), and $(configuration) are Visual Studio Macros, so this command will be translated into:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv" "D:\Learning\MySolutionFolder\MySolutionName.sln" /Build Debug /project "D:\Learning\MySolutionFolder\MyProjectFolder\MyProject.csproj"
"$(DevEnvDir)devenv" "$(SolutionPath)" /Rebuild $(configuration) /project "$(SolutionDir)MyProjectFolder\MyProject.csproj"
Tested now on Visual Studio Community 16.11.1
Using the below command in visual studio 2019, build is faster with msbuild as compared to "$(DevEnvDir)devenv".
msbuild "$(SolutionDir)Sample.sln" /p:configuration=$(configuration)