Build VS2008 projects with .Net 2.0/.Net 3.5 using

2019-09-07 05:22发布

问题:

I'm trying to write a build file to build a simple C# solution but it is failing with the error: Unknown task or datatype.

My solution is written in VS2008 but targeted at .Net 2.0 (I'm using Vista if that helps).

I've already seen the other question running-builds-using-net-3-5-msbuild-and-nantcontrib and have tried the suggested solution and have made the change to my NAnt.exe.config file.

I've tried changing the solution properties to target .net 3.5 (and changing the build file accordingly, but with no success).

Can anyone suggest anything I might be missing?

My build file is as follows:

<?xml version="1.0"?>
    <project name="HelloWorld" default="build" basedir=".">
    <description>Builds the HelloWorld project.</description>
    <target name="build" description="compiles the source code">
        <echo>Building Hello World</echo>
        <property name="nant.settings.currentframework" value="net-2.0" />
        <msbuild project="HelloWorld.sln">
            <property name="Configuration" value="debug" />
        </msbuild>
    </target>
</project>

回答1:

ms build is a task in the Nantcontrib library. You have to download that put it where your build tool can get to it and then before the msbuild task use the LoadTask:

<loadtasks assembly="c:\foo\NAnt.Contrib.Tasks.dll" />

Once you do this it should work fine.