Code Scraps: GenerateApplicationManifest build error in Visual Studio

I got an unusual error in Visual Studio the other day that I hadn’t encountered before. The error was relating to an issue doing App.Config Transformations on a C# Windows application.

The environment was Visual Studio 2013, and the project was a .Net Framework 4.5.1 with the Configuration Transformation VS Plugin installed.

The error read:

“obj\Debug\MyProject.csproj.MyProject.exe.config;obj\Debug\MyProject.exe.config” is an invalid value for the “ConfigFile” parameter of the “GenerateApplicationManifest” task. Multiple items cannot be passed into a parameter of type “Microsoft.Build.Framework.ITaskItem”.

I tried clearing the obj and bin directories out and tried changing the build configurations around a bit but couldn’t get rid of the error. After a bit of digging around I found I could get rid of the error by altering the .csproj file’s AfterCompile declaration.

I altered:

<AppConfigWithTargetPath Remove=”app.config”/>

To:

<AppConfigWithTargetPath Remove=”@(AppConfigWithTargetPath)”/>

This was in the following AfterCompile code block inside the Project .csproj file.

 

<Target Name=”App_config_AfterCompile” AfterTargets=”AfterCompile” Condition=”Exists(‘App.$(Configuration).config’)”>
<!–Generate transformed app config in the intermediate directory–>
<TransformXml Source=”App.config” Destination=”$(IntermediateOutputPath)$(TargetFileName).config” Transform=”App.$(Configuration).config” />
<!–Force build process to use the transformed configuration file from now on.–>
<ItemGroup>
<AppConfigWithTargetPath Remove=”app.config”/>
<AppConfigWithTargetPath Include=”$(IntermediateOutputPath)$(TargetFileName).config”>
<TargetPath>$(TargetFileName).config</TargetPath>
</AppConfigWithTargetPath>
</ItemGroup>
</Target>

 

Once the value in this code block was changed and the project reloaded, the build error I experienced went away. This is the first time I’ve experienced this error – hopefully it’ll be the last.

If this was helpful for you – or you can recommend any other resolutions for this error, drop me a comment! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.