3

I added app.config transforms to an existing Windows Forms client application that uses ClickOnce publishing, and now it will not publish. Error message:

"obj\Release\Client.csproj.App.config;obj\Release\MyAppName.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"

When I uncheck "Enable ClickOnce security settings" (project properties > Security), the project will build and run from Visual Studio 2015 without this error, but when I try to publish using ClickOnce, the error returns. Enabling security results in the project not building at all. Either way, the error is the same.

The app.config is set to to "Copy Always".

I tried removing the clickonce certificate and installing a new one with no difference in symptoms.

Note this is a Windows Forms application, not a web app. The transforms were created using the Configuration Transform extension (works the same as SlowCheetah). I've used this setup for other applications successfully, and so far haven't found a difference in the settings between this app and the successful ones.

This section of the .csproj file seems to be related to the issue:

<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.Tasks.dll" />
      <Target Name="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>

Another post suggested removing the ItemGroup node. When I do this, the project builds and runs in VS, and is able to be published to a test location, but the app.config transform doesn't happen.

jay-danger
  • 505
  • 6
  • 12
  • Update: in the interest of getting the publish to happen timely, I have removed the transforms in favor of a basic app.config for now. I would still prefer to resolve the original issue and use transforms though. – jay-danger Jun 19 '17 at 18:19

2 Answers2

3

If the accepted answer does not work for you (like it did not for me). Please see the solution to this question:

I ran into this same problem. What fixed it for me was changing the line in the transform from above

from

<AppConfigWithTargetPath Remove="app.config" />

to

<AppConfigWithTargetPath Remove="@(AppConfigWithTargetPath)" />
Community
  • 1
  • 1
Marko
  • 29
  • 3
  • This should be the accepted answer because it works for all cases, not someone case that the OP had. – TK-421 Mar 18 '20 at 13:07
1

Resolved: these symptoms were caused by Microsoft.Bcl not playing well with config transforms and ClickOnce publishing together. This app was created with .NET 4 using Bcl in order to use the async/await pattern while running on old XP machines. Our users have upgraded to Windows 7 & 10 since then, so I was able to upgrade the app to .NET 4.5.2 and remove the Bcl packages. With Bcl gone, the issue is completely resolved. (There may be some kind of hack to get Bcl to work correctly with config transforms and clickonce, but since I was able to upgrade, am not pursuing it further).

jay-danger
  • 505
  • 6
  • 12