gpt4 book ai didi

Winforms ClickOnce 发布因 app.config 转换而失败

转载 作者:行者123 更新时间:2023-12-03 06:30:55 27 4
gpt4 key购买 nike

我添加了 app.config 转换为使用 ClickOnce 发布的现有 Windows 窗体客户端应用程序,但现在它不会发布。错误信息:

"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"

当我取消选中“启用 ClickOnce 安全设置”(项目属性 > 安全性)时,项目将从 Visual Studio 2015 生成并运行,而不会出现此错误,但当我尝试使用 ClickOnce 发布时,错误又出现。启用安全性会导致项目根本无法构建。无论哪种方式,错误都是相同的。

app.config 设置为“始终复制”。

我尝试删除 clickonce 证书并安装新证书,症状没有任何差异。

请注意,这是 Windows 窗体应用程序,而不是 Web 应用程序。转换是使用 Configuration Transform 创建的扩展(与 SlowCheetah 工作方式相同)。我已成功将此设置用于其他应用程序,到目前为止,尚未发现此应用程序与成功应用程序之间的设置存在差异。

.csproj 文件的这一部分似乎与该问题相关:

<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>

另一篇文章建议删除 ItemGroup 节点。当我这样做时,项目会在 VS 中构建并运行,并且能够发布到测试位置,但 app.config 转换不会发生。

最佳答案

如果接受的答案对您不起作用(就像对我不起作用一样)。请参阅此问题的解决方案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)" />

关于Winforms ClickOnce 发布因 app.config 转换而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44593380/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com