MSB4067:元素 <Target> 下的元素 <#text> 无法识别

M00*_*005 3 msbuild visual-studio

从 Visual Studio 中,我能够成功编译代码,但是当我尝试使用 MSBuild 编译代码时,它会抛出如下错误

\n\n
\n

MSB4067: 元素 Target 下的元素 <#text> 无法识别。

\n
\n\n

请注意:我在发布模式下使用 MSBuild 构建代码,我为 AfterTarget 添加的代码仅适用于调试模式。

\n\n

如果我删除代码,即比它工作正常。

\n\n

这是我的 csproj 文件

\n\n
<?xml version="1.0" encoding="utf-8"?>\n<Project ToolsVersion="12.0" DefaultTargets="Build" \nxmlns="http://schemas.microsoft.com/developer/msbuild/2003">\n<PropertyGroup>\n<Configuration Condition=" \'$(Configuration)\' == \'\' ">Debug</Configuration>\n<Platform Condition=" \'$(Platform)\' == \'\' ">AnyCPU</Platform>\n<ProductVersion>8.0.30703</ProductVersion>\n<SchemaVersion>2.0</SchemaVersion>\n<ProjectGuid>{B9B35177-B239-41A9-946F-3BB1CC14BD3B}</ProjectGuid>\n<OutputType>Exe</OutputType>\n<AppDesignerFolder>Properties</AppDesignerFolder>\n<RootNamespace>ABC.MyProject.Engine</RootNamespace>\n<AssemblyName>ABC.MyProject.Engine</AssemblyName>\n<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>\n<FileAlignment>512</FileAlignment>\n<TargetFrameworkProfile />\n</PropertyGroup>\n<PropertyGroup Condition=" \'$(Configuration)|$(Platform)\' == \'Debug|AnyCPU\' ">\n<DebugSymbols>true</DebugSymbols>\n<DebugType>full</DebugType>\n<Optimize>false</Optimize>\n<OutputPath>bin\\Debug\\</OutputPath>\n<DefineConstants>DEBUG;TRACE</DefineConstants>\n<ErrorReport>prompt</ErrorReport>\n<WarningLevel>4</WarningLevel>\n<Prefer32Bit>false</Prefer32Bit>\n </PropertyGroup>\n <PropertyGroup Condition=" \'$(Configuration)|$(Platform)\' == \'Release|AnyCPU\' ">\n<DebugType>pdbonly</DebugType>\n<Optimize>true</Optimize>\n<OutputPath>bin\\Release\\</OutputPath>\n<DefineConstants>TRACE</DefineConstants>\n<ErrorReport>prompt</ErrorReport>\n<WarningLevel>4</WarningLevel>\n<Prefer32Bit>false</Prefer32Bit>\n</PropertyGroup>\n<PropertyGroup>\n<StartupObject />\n</PropertyGroup>\n<ItemGroup>\n<Reference Include="ABCDataAccess, Version=2017.2.1.0, Culture=neutral, processorArchitecture=MSIL">\n  <SpecificVersion>False</SpecificVersion>\n  <HintPath>..\\lib\\internal\\ABCDataAccess.dll</HintPath>\n</Reference>\n<Reference Include="ABCNotifier, Version=2016.2.2.0, Culture=neutral, processorArchitecture=MSIL">\n  <SpecificVersion>False</SpecificVersion>\n  <HintPath>..\\lib\\internal\\ABCNotifier.dll</HintPath>\n</Reference>\n<Reference Include="ABCScheduler, Version=2016.2.2.0, Culture=neutral, processorArchitecture=MSIL">\n  <SpecificVersion>False</SpecificVersion>\n  <HintPath>..\\lib\\internal\\ABCScheduler.dll</HintPath>\n</Reference>\n<Reference Include="log4net">\n  <HintPath>..\\lib\\thirdparty\\log4net.dll</HintPath>\n</Reference>\n<Reference Include="System" />\n<Reference Include="System.configuration" />\n<Reference Include="System.Core" />\n<Reference Include="System.Xml.Linq" />\n<Reference Include="System.Data.DataSetExtensions" />\n<Reference Include="Microsoft.CSharp" />\n<Reference Include="System.Data" />\n<Reference Include="System.Xml" />\n</ItemGroup>\n<ItemGroup>\n<Compile Include="core.cs" />\n<Compile Include="Model\\FileInstance.cs" />\n<Compile Include="Model\\FileLifeCycle.cs" />\n<Compile Include="Model\\StateExecutor.cs" />\n<Compile Include="Properties\\AssemblyInfo.cs" />\n<Compile Include="Properties\\Settings.Designer.cs">\n  <AutoGen>True</AutoGen>\n  <DesignTimeSharedInput>True</DesignTimeSharedInput>\n  <DependentUpon>Settings.settings</DependentUpon>\n</Compile>\n<Compile Include="Enterprise\\Implementation\\FileKarmaHandler.cs" />\n<Compile Include="Enterprise\\Implementation\\FileKarma.cs" />\n<Compile Include="Enterprise\\Implementation\\FileLifeCycleData.cs" />\n<Compile Include="Enterprise\\Interface\\IFileLifeCycleData.cs" />\n</ItemGroup>\n<ItemGroup>\n<None Include="app.config" />\n<None Include="Properties\\Settings.settings">\n  <Generator>SettingsSingleFileGenerator</Generator>\n  <LastGenOutput>Settings.Designer.cs</LastGenOutput>\n</None>\n</ItemGroup>\n<ItemGroup>\n<ProjectReference Include="..\\Core\\ABC.MyProject.Core.csproj">\n  <Project>{E1B4DF28-23C5-4865-B7B7-51707D2116E3}</Project>\n  <Name>ABCCore</Name>\n </ProjectReference>\n </ItemGroup>\n<ItemGroup>\n<Content Include="Config\\Archiver.xml" />\n<Content Include="Config\\ABClog.xml" />\n<Content Include="Config\\DataAccess.xml" />\n<Content Include="Config\\Notifier.xml" />\n<Content Include="Config\\Security.xml" />\n</ItemGroup>\n<Import Project="$(MSBuildToolsPath)\\Microsoft.CSharp.targets" />\n<PropertyGroup>\n<PreBuildEvent>\n  rmdir config\n  mkdir config\n  rmdir sqls\n  mkdir sqls\n  rmdir templates\n  mkdir templates\n  exit 0\n</PreBuildEvent>\n</PropertyGroup>\n\n<PropertyGroup>\n <PostBuildEvent>\n  copy $(ProjectDir)Config\\*.xml config\\\n  copy $(ProjectDir)..\\lib\\thirdparty\\*.* $(ProjectDir)\\bin\\$(Configuration)\\\n  copy $(ProjectDir)..\\Core\\Config\\*.xml config\\\n  copy $(ProjectDir)..\\Core\\sqls\\*.*  sqls\\\n</PostBuildEvent>\n</PropertyGroup>\n\n<UsingTask TaskName="XmlPreprocess" AssemblyFile="..\\lib\\msbuild\\lib\\XmlPreprocess.MSBuildTasks.dll" />\n\n<Target Name="AfterBuild" Condition="\'$(Configuration)\' == \'Debug\' ">\n\xc2\xa0\n<PropertyGroup> \n <ConfigValuesSpreadsheetFileLocation>\n  ..\\lib\\msbuild\\config\\Settings.xls\n</ConfigValuesSpreadsheetFileLocation>\n</PropertyGroup>\n<XmlPreprocess\n  ToolPath="..\\lib\\msbuild\\lib\\"\n  InputFiles="..\\Core\\Config\\AlertParams.xml"\n  OutputFiles="bin\\Debug\\config\\AlertParams.xml"\n  SpreadsheetFiles="$(ConfigValuesSpreadsheetFileLocation)"\n  Environment="$(Configuration)"\n  Clean="true"\n  Validate="true" />\n\xc2\xa0\n<XmlPreprocess\n  ToolPath="..\\lib\\msbuild\\lib\\"\n  InputFiles="..\\Core\\Config\\CoreParams.xml"\n  OutputFiles="bin\\Debug\\config\\CoreParams.xml"\n  SpreadsheetFiles="$(ConfigValuesSpreadsheetFileLocation)"\n  Environment="$(Configuration)"\n  Clean="true"\n  Validate="true" />\n\xc2\xa0\n<XmlPreprocess\n  ToolPath="..\\lib\\msbuild\\lib\\"\n  InputFiles="..\\Core\\Config\\StateParams.xml"\n  OutputFiles="bin\\Debug\\config\\StateParams.xml"\n  SpreadsheetFiles="$(ConfigValuesSpreadsheetFileLocation)"\n  Environment="$(Configuration)"\n  Clean="true"\n  Validate="true" />\n\xc2\xa0\n<XmlPreprocess\n  ToolPath="..\\lib\\msbuild\\lib\\"\n  InputFiles="Config\\Archiver.xml"\n  OutputFiles="bin\\Debug\\config\\Archiver.xml"\n  SpreadsheetFiles="$(ConfigValuesSpreadsheetFileLocation)"\n  Environment="$(Configuration)"\n  Clean="true"\n  Validate="true" />\n\xc2\xa0\n<XmlPreprocess\n  ToolPath="..\\lib\\msbuild\\lib\\"\n  InputFiles="Config\\DataAccess.xml"\n  OutputFiles="bin\\Debug\\config\\DataAccess.xml"\n  SpreadsheetFiles="$(ConfigValuesSpreadsheetFileLocation)"\n  Environment="$(Configuration)"\n  Clean="true"\n  Validate="true" />\n\xc2\xa0\n<XmlPreprocess\n  ToolPath="..\\lib\\msbuild\\lib\\"\n  InputFiles="app.config"\n  OutputFiles="bin\\Debug\\app.config"\n  SpreadsheetFiles="$(ConfigValuesSpreadsheetFileLocation)"\n  Environment="$(Configuration)"\n  Clean="true"\n  Validate="true" />\n\n  </Target>\n\n</Project>\n
Run Code Online (Sandbox Code Playgroud)\n

Dav*_*urg 5

我见过当 XML 格式不正确时会发生此错误,例如具有重复的 > 字符。要对其进行故障排除,您可以从 csproj 中删除 XML 节点,直到错误消失(它应该在构建开始时),然后重复操作,直到缩小到存在 XML 问题的特定行。