Msbuild 以编程方式构建.net3.5项目会导致错误MSB4067:元素<;ImportGroup>;下元素<;项目>;未被承认
我已经编写了下面的代码以编程方式构建.net3.5项目Msbuild 以编程方式构建.net3.5项目会导致错误MSB4067:元素<;ImportGroup>;下元素<;项目>;未被承认,msbuild,.net-3.5,Msbuild,.net 3.5,我已经编写了下面的代码以编程方式构建.net3.5项目 var engine = new Engine { DefaultToolsVersion = "3.5", BinPath = @"C:\Windows\Microsoft.NET\Framework64\v3.5" }; var logger = new FileLogger { Parameter
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"
“错误MSB4067:无法识别元素下的元素”
我知道将项目更新到.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>
调试
任意CPU
{14D56AA1-C68E-4AC4-B114-CFD1A22B6D1C}
图书馆
性质
Tosan.GeneratedProduct.GL.Common
Tosan.GeneratedProduct.GL.Common
v3.5
512
萨克
萨克
萨克
萨克
真的
满的
假的
..\..\..\输出\
调试;痕迹
促使
4.
pdbonly
真的
bin\Release\
痕迹
促使
4.
..\..\..\..\sharedlls\Tosan.Framework.dll
..\..\..\..\SharedDLS\Tosan.Framework.Interfaces.dll
..\..\..\..\sharedlls\Tosan.Framework.Java.dll
..\..\..\..\sharedlls\Tosan.Global.Data.dll
假的
..\..\..\..\SharedDLS\ValidationFramework.dll
..\..\..\..\sharedlls\Tosan.Framework.dll
..\..\..\..\sharedlls\Tosan.Framework.dll
多谢各位