将XBAP集成到ASP.NET Web应用程序、持续集成服务器和发布流程中

发布于 2024-08-08 11:28:17 字数 1068 浏览 2 评论 0原文

您好,我正在听取那些已经实现了 WPF 基于 Web 的应用程序或 XAML 浏览器应用程序 (XBAP) 的人的建议,这些应用程序需要完全信任,进入持续集成服务器(例如 CruiseControl.NET)以及正常的构建/发布过程。

具体来说,我感兴趣的是:

  1. 签署需要完全信任的 XBAP 项目
    PFX 文件是可行的方法,还是使用 CI 服务器时更好的方法?
    (我们昨天遇到了此问题 )。

  2. 将 XBAP 项目发布到 ASP.NET Web 应用程序
    2.1 这应该在“发布”配置构建中自动化吗?
    2.2 发布的输出是否应该进入 Bin 目录?
    2.3 如果可能的话,我们是否应该避免 .deploy 文件扩展名并重用现有程序集?
    (ASP.NET Web 应用程序项目中已使用了许多类库)

  3. 部署 XBAP 需要完全信任才能从 ASP.NET Web 应用程序使用

  4. 对 XBAP 项目进行版本控制
    我们是否应该使用与 ASP.NET Web 应用程序项目中的其余程序集相同的版本?

背景信息:

  • XBAP 项目用于设计在我们的 ASP.NET Web 应用程序中使用的报告。它是产品的一个组成部分。
  • 编译 XBAP 和 Web 应用程序项目后,我们使用 Web 部署项目,然后我们的 Wix 项目使用该项目的输出来构建 MSI 安装程序。
  • 我们使用 CruiseControl.NET 进行 CI,使用 Subversion 进行 RCS,使用 MSBuild 将所有内容粘合在一起,整个构建/发布过程是自动化的,并且需要保持这种状态。

任何建议表示赞赏!

Greetings, I'm after advice from those who have implemented an WPF Web Based Application or XAML Browser Application (XBAP) which requires full trust, into a continuous integration server such as CruiseControl.NET, as well as their normal build/release process.

Specifically, I'm interested in:

  1. Signing an XBAP project which requires full trust.
    Are PFX files the way to go, or is this a better approach when using a CI server?
    (We hit this problem yesterday).

  2. Publishing an XBAP project into an ASP.NET web application.
    2.1 Should this be automated on "Release" configuration builds?
    2.2 Should the published output go into the Bin directory?
    2.3 Should we avoid .deploy file extensions and reuse existing assemblies if possible?
    (there are many class libraries already used in the ASP.NET web app project)

  3. Deploying XBAP requiring full trust for use from an ASP.NET web application.

  4. Versioning XBAP project.
    Should we use the same version as the rest of our assemblies in the ASP.NET web app project?

Background info:

  • The XBAP project is for designing reports for use in our ASP.NET web app. It's an integrated part of the product.
  • After compiling XBAP and web application projects, we use a web deployment project and the output of that is then used by our Wix projects to build MSI installers.
  • We use CruiseControl.NET for CI, Subversion for RCS, MSBuild to glue everything together, and the whole build/release process is automated, and needs to stay that way.

Any advice appreciated!

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

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

发布评论

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

评论(1

孤者何惧 2024-08-15 11:28:17

这是迄今为止我们发现的内容。当然,这不是“最佳实践”,但它是一个开始:

签署需要完全信任的 XBAP 项目。

一旦我弄清楚如何 ,PFX 就工作正常解决 CI 服务器作为服务运行的问题

将 XBAP 项目发布到 ASP.NET Web 应用程序中。
2.1 这应该在“发布”配置构建中自动化吗?
2.2 发布的输出是否应该进入 Bin 目录?
2.3 如果可能的话,我们是否应该避免.deploy 文件扩展名并重用现有程序集?

复制到 Bin 会导致 IIS7 中的 RequestFilteringModule 出现问题,因此我们没有使用它。

我们没有发布,而是在 AfterBuild 目标中将输出复制到 ASP.NET Web 应用程序中的一个目录中,该目录会被 Subversion 忽略,但不会被 Web 部署或 wix 项目忽略。
因此,我们复制所需的内容(dll、exe、manifest、xbap),然后使用一些 MSBuild 魔法将其重命名为 .deploy 扩展名,因为某些客户端可能会阻止 .exe 或 .dll 下载:

<Target Name="AfterBuild">
  <CallTarget Targets="CopyOutputToDeployWebDir" />
</Target>

<Target Name="CopyOutputToDeployWebDir">
  <CreateProperty Value="..\Path\To\Application\Dir">
    <Output TaskParameter="Value" PropertyName="DeployWebDir" />
  </CreateProperty>
  <RemoveDir Directories="$(DeployWebDir)" />
  <MakeDir Directories="$(DeployWebDir)" />
  <ItemGroup>
    <DeployWebFiles  Include="$(OutputPath)*.dll;$(OutputPath)*.exe;$(OutputPath)*.manifest;$(OutputPath)*.xbap" />
   </ItemGroup>
   <Copy SourceFiles="@(DeployWebFiles)" DestinationFolder="$(DeployWebDir)" />
   <ItemGroup>
     <RenameFiles Include="$(DeployWebDir)*.dll;$(DeployWebDir)*.exe" />
   </ItemGroup>
   <Move SourceFiles="@(RenameFiles)" DestinationFiles="%(RenameFiles.FullPath).deploy" />
</Target>

部署 XBAP 需要完全信任才能从 ASP.NET Web 应用程序使用。

目前看来我们需要在受信任的根证书存储和受信任的发布者证书存储中安装签名密钥。

对 XBAP 项目进行版本控制。

我们想要与我们的 ASP.NET Web 应用程序版本相同的 XBAP 应用程序版本(在我们的例子中是 AssemblyFileVersion 属性),因此我们结束了绕过正常的 ApplicationVersion 属性方法,从我们的共享 AssemblyInfo 文件覆盖它,该文件由中的所有程序集使用产品:

<!-- Note that this value is overridden in BeforeBuild target -->
<ApplicationVersion>0.0.0.0</ApplicationVersion>
<!-- ... -->
<Target Name="BeforeBuild">
  <CallTarget Targets="SetApplicationVersion" />
</Target>
<!-- Always set application version to product version -->
<Target Name="SetApplicationVersion">
  <UpdateVersion Attribute="AssemblyFileVersion" AssemblyInfo="..\ProductAssemblyInfo.cs">
    <Output PropertyName="ApplicationVersion" TaskParameter="Version" />
  </UpdateVersion>
</Target>

UpdateVersion 是一个自定义 MSBuild 任务,可以在 AssemblyInfo 文件中读取或写入版本属性值。编写或在网上找到一些东西来做类似的事情并不难。

Here's what we've found so far. Of course it's not 'best practice' but it's a start:

Signing an XBAP project which requires full trust.

PFX is working fine once I figured out how to solve the issue with the CI server running as a service.

Publishing an XBAP project into an ASP.NET web application.
2.1 Should this be automated on "Release" configuration builds?
2.2 Should the published output go into the Bin directory?
2.3 Should we avoid .deploy file extensions and reuse existing assemblies if possible?

Copying to Bin caused problems with the RequestFilteringModule in IIS7 so we didn't use it.

Instead of publishing, in the AfterBuild target we copy the output into a directory in our ASP.NET web app, which is ignored by Subversion, but not by the web deploy or wix project.
So we copy what we need (dll,exe,manifest,xbap) and then use some MSBuild magic to rename to .deploy extensions, because some clients might block .exe or .dll downloads:

<Target Name="AfterBuild">
  <CallTarget Targets="CopyOutputToDeployWebDir" />
</Target>

<Target Name="CopyOutputToDeployWebDir">
  <CreateProperty Value="..\Path\To\Application\Dir">
    <Output TaskParameter="Value" PropertyName="DeployWebDir" />
  </CreateProperty>
  <RemoveDir Directories="$(DeployWebDir)" />
  <MakeDir Directories="$(DeployWebDir)" />
  <ItemGroup>
    <DeployWebFiles  Include="$(OutputPath)*.dll;$(OutputPath)*.exe;$(OutputPath)*.manifest;$(OutputPath)*.xbap" />
   </ItemGroup>
   <Copy SourceFiles="@(DeployWebFiles)" DestinationFolder="$(DeployWebDir)" />
   <ItemGroup>
     <RenameFiles Include="$(DeployWebDir)*.dll;$(DeployWebDir)*.exe" />
   </ItemGroup>
   <Move SourceFiles="@(RenameFiles)" DestinationFiles="%(RenameFiles.FullPath).deploy" />
</Target>

Deploying XBAP requiring full trust for use from an ASP.NET web application.

At the moment it looks like we need to install signed key in both the Trusted Root Certificate Store and Trusted Publishers Certificate Store.

Versioning XBAP project.

We want the same XBAP application version as our ASP.NET web application version (in our case, AssemblyFileVersion attribute), so we ended by-passing the normal ApplicationVersion property approach, overwriting it from our shared AssemblyInfo file which is used by all assemblies in the product:

<!-- Note that this value is overridden in BeforeBuild target -->
<ApplicationVersion>0.0.0.0</ApplicationVersion>
<!-- ... -->
<Target Name="BeforeBuild">
  <CallTarget Targets="SetApplicationVersion" />
</Target>
<!-- Always set application version to product version -->
<Target Name="SetApplicationVersion">
  <UpdateVersion Attribute="AssemblyFileVersion" AssemblyInfo="..\ProductAssemblyInfo.cs">
    <Output PropertyName="ApplicationVersion" TaskParameter="Version" />
  </UpdateVersion>
</Target>

UpdateVersion is a custom MSBuild task that can read or write version attribute values in an AssemblyInfo file. It's not hard to write or find something on the web to do a similar thing.

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