我已编写代码来编程.net3.5项目编程,
var engine = new Engine
{
DefaultToolsVersion = "3.5",
BinPath = @"C:\Windows\Microsoft.NET\Framework64\v3.5"
};
var logger = new FileLogger { Parameters = @"logfile=" + MsBuildLogPath};
engine.RegisterLogger(logger);
var properties = new BuildPropertyGroup();
properties.SetProperty("Configuration", "release");
properties.SetProperty("OutputPath", @"bin\Release\");
properties.SetProperty("Platform", "Any CPU");
properties.SetProperty("TargetFrameworkVersion", "3.5");
properties.SetProperty("OutputPath", destinationPath + @"\Output");
bool result = engine.BuildProjectFile(solutionPath, new[] { "rebuild" }, properties);
我的msbuild路径是" C:\ Windows \ Microsoft.NET \ Framework64 \ v3.5"由于我的构建器项目基于.net3.5,并且出于某些原因我无法将其更新为.net4 。
编译项目导致错误
"error MSB4067: The element <ImportGroup> beneath element <Project> is unrecognized"
我知道将我的项目更新为.net4并使用构建引擎4.0解决了我的问题,但正如我之前所说的由于某种原因我无法将我的项目更新为.net4并将构建路径切换到.net4 / msbuild。那么我该怎么做才能解决这个错误呢?
这是我的项目文件内容,不包含ImportGroup标记!
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{14D56AA1-C68E-4AC4-B114-CFD1A22B6D1C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Tosan.GeneratedProduct.GL.Common</RootNamespace>
<AssemblyName>Tosan.GeneratedProduct.GL.Common</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\Output\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Tosan.Framework">
<HintPath>..\..\..\..\SharedDlls\Tosan.Framework.dll</HintPath>
</Reference>
<Reference Include="Tosan.Framework.Interfaces">
<HintPath>..\..\..\..\SharedDlls\Tosan.Framework.Interfaces.dll</HintPath>
</Reference>
<Reference Include="Tosan.Framework.Java">
<HintPath>..\..\..\..\SharedDlls\Tosan.Framework.Java.dll</HintPath>
</Reference>
<Reference Include="Tosan.Global.Data">
<HintPath>..\..\..\..\SharedDlls\Tosan.Global.Data.dll</HintPath>
</Reference>
<Reference Include="ValidationFramework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=2f07bd240683f08a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\SharedDlls\ValidationFramework.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Data\" />
<Folder Include="Enum\" />
<Folder Include="Filter\" />
<Folder Include="Interface\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<Reference Include="Tosan.Framework, Version=3.17.6258.18262, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\..\..\SharedDlls\Tosan.Framework.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Data\customer.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="Data\CustomerDebit.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Tosan.Framework, Version=3.18.6429.18915, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\..\..\SharedDlls\Tosan.Framework.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
谢谢。