Manual XBAP publishing

烈酒焚心 提交于 2019-12-06 05:10:41

I had to alter the name of the default "Application Files" folder for one of our customers who doesn't like spaces in file or folder names and this meant re-signing the xbap after the publish. Here's the msbuild script I use to automate the process:

<Target Name="PublishWebsite" DependsOnTargets="CleanWebsiteOutputPath;CleanOutputPath;CleanWebsiteReleasePath">

    <!-- Compile Website -->
    <MSBuild Projects=".\Some.Namespace.Web.Site\Some.Namespace.UI.Web.Site.csproj" Targets="Clean;Rebuild;" Properties="Configuration=Release" />

    <!-- Copy Website files to release folder -->
    <ItemGroup>
        <SiteFiles Include="Some.Namespace.UI.Web.Site/**/*.*" />
    </ItemGroup>
    <Copy SourceFiles="@(SiteFiles)" DestinationFolder="..\rel\Website\%(RecursiveDir)" />

    <!-- Remove source code and source control files from website -->
    <CallTarget Targets="CleanWebsiteAfterPublish" />
    <Message Text="Website Published" />

    <!-- Rename "Application Files" folder and re-sign the xbap -->
    <StringReplace Pattern="\." InputString="$(ApplicationVersion)" Replace="_">
        <Output PropertyName="VersionUnderscored" TaskParameter="Result" />
    </StringReplace>
    <MSBuild Projects=".\Some.Namespace.UI.WPF\Some.Namespace.UI.WPF.csproj" Targets="Publish" Properties="Configuration=Release;" />
    <Exec Command="move &quot;..\bin\Release\app.publish\Application Files&quot; &quot;..\bin\Release\app.publish\ApplicationFiles&quot;" />
    <Exec Command="$(MageExe) -update ..\bin\Release\app.publish\SomeApp.xbap –AppManifest ..\bin\Release\app.publish\ApplicationFiles\SomeApp_$(VersionUnderscored)\SomeApp.exe.manifest -wpf true -cf ..\ext\Signing\SomeApp.pfx -pwd password" />

    <!-- Move published files to Release directory -->
    <ItemGroup>
        <XbapPublishFiles Include="..\bin\Release\app.publish\**\*.*" />
    </ItemGroup>
    <Copy SourceFiles="@(XbapPublishFiles)" DestinationFiles="@(XbapPublishFiles->'..\rel\Website\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Message Text="XBAP Published" />
</Target>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!