Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSB4067: The element <#text> beneath element <Target> is unrecognized

From the visual studio, I am able to compile code successfully but when I am trying to compile code using MSBuild, it throws me error like below

MSB4067: The element <#text> beneath element Target is unrecognized.

Please note: I am building code using MSBuild in release mode, the code which I have added for AfterTarget is only for Debug mode.

If I remove code i.e. than it is working fine.

Here is my csproj file

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

<PropertyGroup>
 <PostBuildEvent>
  copy $(ProjectDir)Config\*.xml config\
  copy $(ProjectDir)..\lib\thirdparty\*.* $(ProjectDir)\bin\$(Configuration)\
  copy $(ProjectDir)..\Core\Config\*.xml config\
  copy $(ProjectDir)..\Core\sqls\*.*  sqls\
</PostBuildEvent>
</PropertyGroup>

<UsingTask TaskName="XmlPreprocess" AssemblyFile="..\lib\msbuild\lib\XmlPreprocess.MSBuildTasks.dll" />

<Target Name="AfterBuild" Condition="'$(Configuration)' == 'Debug' ">
 
<PropertyGroup> 
 <ConfigValuesSpreadsheetFileLocation>
  ..\lib\msbuild\config\Settings.xls
</ConfigValuesSpreadsheetFileLocation>
</PropertyGroup>
<XmlPreprocess
  ToolPath="..\lib\msbuild\lib\"
  InputFiles="..\Core\Config\AlertParams.xml"
  OutputFiles="bin\Debug\config\AlertParams.xml"
  SpreadsheetFiles="$(ConfigValuesSpreadsheetFileLocation)"
  Environment="$(Configuration)"
  Clean="true"
  Validate="true" />
 
<XmlPreprocess
  ToolPath="..\lib\msbuild\lib\"
  InputFiles="..\Core\Config\CoreParams.xml"
  OutputFiles="bin\Debug\config\CoreParams.xml"
  SpreadsheetFiles="$(ConfigValuesSpreadsheetFileLocation)"
  Environment="$(Configuration)"
  Clean="true"
  Validate="true" />
 
<XmlPreprocess
  ToolPath="..\lib\msbuild\lib\"
  InputFiles="..\Core\Config\StateParams.xml"
  OutputFiles="bin\Debug\config\StateParams.xml"
  SpreadsheetFiles="$(ConfigValuesSpreadsheetFileLocation)"
  Environment="$(Configuration)"
  Clean="true"
  Validate="true" />
 
<XmlPreprocess
  ToolPath="..\lib\msbuild\lib\"
  InputFiles="Config\Archiver.xml"
  OutputFiles="bin\Debug\config\Archiver.xml"
  SpreadsheetFiles="$(ConfigValuesSpreadsheetFileLocation)"
  Environment="$(Configuration)"
  Clean="true"
  Validate="true" />
 
<XmlPreprocess
  ToolPath="..\lib\msbuild\lib\"
  InputFiles="Config\DataAccess.xml"
  OutputFiles="bin\Debug\config\DataAccess.xml"
  SpreadsheetFiles="$(ConfigValuesSpreadsheetFileLocation)"
  Environment="$(Configuration)"
  Clean="true"
  Validate="true" />
 
<XmlPreprocess
  ToolPath="..\lib\msbuild\lib\"
  InputFiles="app.config"
  OutputFiles="bin\Debug\app.config"
  SpreadsheetFiles="$(ConfigValuesSpreadsheetFileLocation)"
  Environment="$(Configuration)"
  Clean="true"
  Validate="true" />

  </Target>

</Project>
like image 420
M005 Avatar asked Nov 19 '25 15:11

M005


1 Answers

I've seen this error happen when the XML is somehow malformed, such as having a duplicated > character. To troubleshoot it you can remove XML nodes from your csproj until the error goes away (it should be right at the build start) and repeat until you narrow down to the specific line with the XML issue.

like image 193
David Burg Avatar answered Nov 22 '25 15:11

David Burg