在安装项目中使用 SlowCheetah 的 app.config 转换

发布于 2024-12-29 14:34:57 字数 668 浏览 1 评论 0原文

我正在使用 SlowCheetah XML Transforms 扩展来处理 Web。使用 app.config 进行类似配置的转换。那部分效果很好。

我添加了一个安装项目并将其配置为包含第一个项目的项目输出。我注意到当我运行安装程序时,它安装了未转换的 app.config。查看主输出(快 10 倍),我注意到它在 Project\bin\Debug\Project.exe 中找到了二进制文件,但是 Project.exe.config 来自 Project\app.config 而不是 Project\bin\Debug\Project.exe.config

我可以从主输出中排除 app.config,并将路径硬编码到特定配置的 app.config (Project\bin\Debug\Project.exe.config),但随后我会无论我使用哪种配置来构建它,都会获得相同的 app.config 。

是否有解决方法可以在安装项目中获取适当的转换后的 app.config?

I'm using the SlowCheetah XML Transforms extension to handle web.config-like transformations with app.config. That part works great.

I added a setup project and configured it to include the project output of the first project. I noticed that when I ran the installer, it installed the non-transformed app.config. Looking at the Primary output Outputs (say that 10 times fast), I noticed that its finding the binary in Project\bin\Debug\Project.exe, but Project.exe.config comes from Project\app.config instead of Project\bin\Debug\Project.exe.config.

I could exclude app.config from the Primary output, and hard-code the path to a specific configuration's app.config (Project\bin\Debug\Project.exe.config), but then I'd get the same app.config regardless of which configuration I used to build it.

Is there a workaround for getting the appropriate transformed app.config in a Setup project?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

海之角 2025-01-05 14:34:57

您好,我们计划在未来几天内发布支持 ClickOnce 的新版本。如果您需要构建之前已修复的插件,请与我联系,我可以将其发送给您。

Hi we are planning on releasing a new version which has ClickOnce support in the next few days. If you need a build of the add in before than which has the fix please contact me and I can get that out to you.

倾城月光淡如水﹏ 2025-01-05 14:34:57

这可能不完全是您正在寻找的答案,但我之前一直在努力解决如何将正确的 app.config 文件放入安装项目中。我有一个使用转换的 TFSBuild.proj msbuild 文件。我认为 SlowCheetah 转换使用相同的 msbuild 任务,但我可能是不正确的。在处理转换文件时,SlowCheetah 无疑提供了更有用的用户体验。我的构建文件采用了稍微不同的方法。在自动构建结束时,我想为每个目标部署环境生成安装程序。我使用了许多 msbuild 扩展,包括 TransformXml 构建任务 - 并非以下所有必需的,但 FWIW 这些是导入:

<!-- import extensions -->
<Import Project="$(MSBuildExtensionsPath)\ExtensionPack\MSBuild.ExtensionPack.tasks"/>
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<UsingTask TaskName="TransformXml"
       AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>

我定义了以下环境:

<ItemGroup>
  <!-- target deployment environments -->
  <Configs Include="Prod" />
  <Configs Include="Staging" />
  <Configs Include="Test" />
</ItemGroup>

然后是标准 AfterCompileSolution target 包含对为每个环境生成安装程序的目标的调用:

<Target Name="AfterCompileSolution">

  <!-- Create installers for target deployment environments -->
  <CallTarget Targets="MyProject" />

</Target>

<Target Name="MyProject" Outputs="%(Configs.Identity)">
  <ItemGroup>
    <MyProjectTempConfig Include="$(SolutionRoot)\MyProjectService\Temp.config" />
    <MyProjectConfigFrom Include="$(SolutionRoot)\MyProjectService\App.%(Configs.Identity).config" />
    <MyProjectConfigTo Include="$(SolutionRoot)\MyProjectService\App.config">
      <Attributes>ReadOnly</Attributes>
    </MyProjectConfigTo>
  </ItemGroup>

  <Message Text="MyProject - Target environment: %(Configs.Identity)" />

  <!-- transform app.config using appropriate -->
  <Copy SourceFiles="@(MyProjectConfigTo)"
        DestinationFiles="@(MyProjectTempConfig)"
        OverwriteReadOnlyFiles="true"
        ContinueOnError="true"
        Condition="!Exists(@(MyProjectTempConfig))"/>

  <File TaskAction="RemoveAttributes" Files="@(MyProjectConfigTo)"/>

  <TransformXml Source="@(MyProjectTempConfig)"
                Transform="@(MyProjectConfigFrom)"
                Destination="@(MyProjectConfigTo)" />

  <!-- run setup -->
  <Exec Command=""$(ProgramFiles)\Microsoft Visual Studio 10.0\Common7\IDE\devenv" "$(SolutionRoot)\MyProject.sln" /build Release /project MyProjectService.Setup"/>

  <!-- rename output for target deployment environment -->
  <Copy SourceFiles="$(SolutionRoot)\MyProjectService.Setup\Release\MyProjectService.msi"
        DestinationFiles="$(OutDir)\%(Configs.Identity)_MyProjectService.msi"
        OverwriteReadOnlyFiles="true"
        ContinueOnError="true"/>

</Target>

This may not be exactly the answer you're looking for but I have previously wrestled with how to get the correct app.config file into a setup project. I have a TFSBuild.proj msbuild file that uses transforms. The SlowCheetah transforms I think use the same msbuild task but I may be incorrect. SlowCheetah certainly provides a more useful user experience when working with transform files. My build file takes a slightly different approach. At the end of the automated build I wanted to generate installers for each of the target deployment environments. I use a number of msbuild extensions, including the TransformXml build task - not all required for the following but FWIW these are the imports:

<!-- import extensions -->
<Import Project="$(MSBuildExtensionsPath)\ExtensionPack\MSBuild.ExtensionPack.tasks"/>
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<UsingTask TaskName="TransformXml"
       AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>

I have the following environments defined:

<ItemGroup>
  <!-- target deployment environments -->
  <Configs Include="Prod" />
  <Configs Include="Staging" />
  <Configs Include="Test" />
</ItemGroup>

Then the standard AfterCompileSolution target contains a call to the target that generates the installer for each environment:

<Target Name="AfterCompileSolution">

  <!-- Create installers for target deployment environments -->
  <CallTarget Targets="MyProject" />

</Target>

<Target Name="MyProject" Outputs="%(Configs.Identity)">
  <ItemGroup>
    <MyProjectTempConfig Include="$(SolutionRoot)\MyProjectService\Temp.config" />
    <MyProjectConfigFrom Include="$(SolutionRoot)\MyProjectService\App.%(Configs.Identity).config" />
    <MyProjectConfigTo Include="$(SolutionRoot)\MyProjectService\App.config">
      <Attributes>ReadOnly</Attributes>
    </MyProjectConfigTo>
  </ItemGroup>

  <Message Text="MyProject - Target environment: %(Configs.Identity)" />

  <!-- transform app.config using appropriate -->
  <Copy SourceFiles="@(MyProjectConfigTo)"
        DestinationFiles="@(MyProjectTempConfig)"
        OverwriteReadOnlyFiles="true"
        ContinueOnError="true"
        Condition="!Exists(@(MyProjectTempConfig))"/>

  <File TaskAction="RemoveAttributes" Files="@(MyProjectConfigTo)"/>

  <TransformXml Source="@(MyProjectTempConfig)"
                Transform="@(MyProjectConfigFrom)"
                Destination="@(MyProjectConfigTo)" />

  <!-- run setup -->
  <Exec Command=""$(ProgramFiles)\Microsoft Visual Studio 10.0\Common7\IDE\devenv" "$(SolutionRoot)\MyProject.sln" /build Release /project MyProjectService.Setup"/>

  <!-- rename output for target deployment environment -->
  <Copy SourceFiles="$(SolutionRoot)\MyProjectService.Setup\Release\MyProjectService.msi"
        DestinationFiles="$(OutDir)\%(Configs.Identity)_MyProjectService.msi"
        OverwriteReadOnlyFiles="true"
        ContinueOnError="true"/>

</Target>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文