Building .NET 4 projects with Nant

后端 未结 8 1073
感动是毒
感动是毒 2020-12-05 02:09

How do I get nant to build projects that target the .NET 4.0 Framework?

相关标签:
8条回答
  • 2020-12-05 02:59

    Just to put the info there so i could find it again, to build C++ projects without modifying the PATH environement variable and creating LIB/LIBPATH/INCLUDE variables or running nant from vsvars32, something like that is needed in Nant config file :

    <project>
        <readregistry
            property="WindowsSdkDir"
            key="SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\InstallationFolder"
            hive="LocalMachine"
            failonerror="true" />
    
        <readregistry
            property="installRoot"
            key="SOFTWARE\Microsoft\.NETFramework\InstallRoot"
            hive="LocalMachine" />
        <readregistry
            property="sdkInstallRoot"
            key="SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx40Tools\InstallationFolder"
            hive="LocalMachine"
            failonerror="false" />
        <readregistry
            property="vs10Win32Tools"
            key="SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-Win32Tools\InstallationFolder"
            hive="LocalMachine"
            failonerror="false" />      
        <readregistry
            property="vcInstallDir"
            key="SOFTWARE\Microsoft\VisualStudio\10.0\Setup\VC\ProductDir"
            hive="LocalMachine"
            failonerror="true" />
        <readregistry
            property="vs10dbghelp"
            key="SOFTWARE\Microsoft\VisualStudio\10.0\Setup\Dbghelp_path"
            hive="LocalMachine"
            failonerror="true" />
    
        <setenv name="PATH" value="${path::combine(vcInstallDir, 'bin')};${vs10dbghelp};${sdkInstallRoot};${vs10Win32Tools};${environment::get-variable('PATH')};" />
        <setenv name="INCLUDE" value="${path::combine(WindowsSdkDir, 'include')};${path::combine(vcInstallDir, 'atlmfc/include')};${path::combine(vcInstallDir, 'include')};${environment::get-variable('INCLUDE')}" />
        <setenv name="LIB" value="${path::combine(WindowsSdkDir, 'lib')};${path::combine(vcInstallDir, 'atlmfc/lib')};${path::combine(vcInstallDir, 'lib')};${environment::get-variable('LIB')}" />
        <setenv name="LIBPATH" value="${path::combine(installRoot, 'v4.0.30319')};${path::combine(installRoot, 'v3.5')};${path::combine(WindowsSdkDir, 'lib')};${path::combine(vcInstallDir, 'atlmfc/lib')};${path::combine(vcInstallDir, 'lib')};${environment::get-variable('LIBPATH')}" />
    </project> 
    

    The registry path are the one of VS2010 as the corresponding SDK is taking it's time...

    0 讨论(0)
  • 2020-12-05 03:03

    This is pretty similar to these questions/problems:

    <msbuild> task or msbuild.exe with NAnt?

    Another option would be to directly call MSBuild from an block.

    <property name="MSBuildPath" value="C:\WINDOWS\Microsoft.NET\Framework\v4.0\MSBuild.exe" />    
    
    <target name="build">
        <exec program="${MSBuildPath}">
                <arg line='"${SolutionFile}"' />
                <arg line="/property:Configuration=${SolutionConfiguration}" />
                <arg value="/target:Rebuild" />
                <arg value="/verbosity:normal" />
                <arg value="/nologo" />
                <arg line='/logger:"C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll"'/>
        </exec>
    </target>
    
    0 讨论(0)
提交回复
热议问题