Search code examples
visual-studio-2012buildpublishnantdevenv

Nant using devenv to build and publish Visual Studio 2012 Solution?


I am attempting to merge a Visual Studio 2010 project to 2012. The 2010 solution had a deployment project which output can be replicated by publishing in 2012. Our build script looking something like this:

<target name="buildSolution">
    <delete file="${BuildRootFolder}\build.log" />
    <exec program="devenv.exe" verbose="true" timeout="2400000"
        commandline='/out build.log ${BuildRootFolder}\Solution.sln /Build "Release" /deploy Solution'
        basedir="C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE">
        <environment>
            <variable name="PATH"
            value="blah blah....">
        </environment>
    </exec>    
</target>

How do I update this to Publish one of the projects in that solution using the publishing profile I defined?


Solution

  • Forget devenv and use msbuild.
    
    <property name="MSBuildPath" value="C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"/>
        <target name="buildSolution" depends="clean">
            <exec program="${MSBuildPath}">
                <arg line='"${BuildRootFolder}\Solution.sln"' />
                <arg line='/property:Configuration="Release";DeployOnBuild=true;PublishProfile=Deployment' />
                <arg value="/target:Build" />
                <arg value="/verbosity:normal" />
                <arg value="/nologo" />
            </exec>
        </target>