Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use MSBuild to build a Visual Studio Setup Project

I am trying to use MSBuild to build a Visual Studio Setup Project using the article below:

http://msdn.microsoft.com/en-us/library/ms404859.aspx https://web.archive.org/web/20090218033835/msdn.microsoft.com/en-us/library/ms404859.aspx

I have followed all the steps mentioned in the article above with the exception of not using TFS in this case.

Instead of using the TFS option, I am trying to create a Demo.proj file and have included the below details: ** - Demo.proj**

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="AfterCompile">
    <Exec Command="&quot;$(ProgramFiles)\Microsoft Visual Studio 9.0\Common7\IDE\devenv&quot; &quot;C:\Users\sapatro\Documents\visual studio 2010\Projects\HelloWorldTest\HelloWorldTestInstaller\HelloWorldTestInstaller.vdproj&quot; /Build &quot;Debug|Any CPU&quot;"/>
    <Copy SourceFiles="C:\Users\sapatro\Documents\visual studio 2010\Projects\HelloWorldTest\HelloWorldTestInstaller\Debug\HelloWorldTestInstaller.msi; C:\Users\sapatro\Documents\visual studio 2010\Projects\HelloWorldTest\HelloWorldTestInstaller\Debug\setup.exe" DestinationFolder="$(OutDir)" />
  </Target>
</Project>

now when I trying to cmd prompt and trying the following command:

msbuild DemoBuild.proj /target:AfterCompile

I am getting the following error:

Build FAILED.

"C:\xxxxxxxxx\Documents\Visual Studio 2010\Projects\HelloWorldTest\DemoBuild.proj" (default target) (1) -> (AfterCompile target) -> C:\xxxxxxxxx\Visual Studio 2010\Projects\HelloWorldTest\DemoBuild.proj(4,5): error MSB3073: The command ""C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv" "C:\xxxxxxxxx\Documents\visual studio 2010\Projects\HelloWorldTest\HelloWorldTestInstaller\HelloWorldTestInstaller.vdproj" /Build "Debug|Any CPU"" exited with code 1.

0 Warning(s)
1 Error(s)

Time Elapsed 00:00:01.25

Can anyone help me to resolve this issue.

Thanks & Regards, Santosh Kumar Patro

like image 374
santosh kumar patro Avatar asked Aug 29 '13 13:08

santosh kumar patro


2 Answers

This works for me:

<Exec Command="&quot;$(ProgramFiles)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.com&quot; your.vdproj /build &quot;Debug|AnyCPU&quot;"/>

You don't need the space in any cpu and you need to call devenv.com, also assuming you have those build configuration existing?

like image 87
James Woolfenden Avatar answered Sep 21 '22 06:09

James Woolfenden


James' answer helped me but I still got an error stating An error occurred while validating.

I had to also do this and finally got it working. For VS2015, add the registry key HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0_Config\MSBuild\EnableOutOfProcBuild and set the value to 0.

like image 23
datchung Avatar answered Sep 23 '22 06:09

datchung