在部署期间生成setup.exe(引导程序)

时间:2015-06-16 17:02:24

标签: powershell clickonce mage

我正在尝试自动部署ClickOnce应用程序。编译非常简单(据我所知),但我从未看到生成setup.exe。我甚至不确定是否应该在构建时或部署时生成setup.exe,我非常确定它应该在部署时生成。 (我在部署期间生成并签署清单,以便它们在每个环境中都是唯一的dev/qual/production

注意:我之前从未使用过ClickOnce,而且我还没有开发这个项目,我的任务就是自动部署它。如果我遗漏了任何内容,请在评论中提问。

以下是我的编译方式

# https://github.com/transcanada/poshBAR/blob/master/src/poshBAR/MSBuild.ps1#L136
Invoke-CleanMSBuild $this.solutions.uiShell

# https://github.com/transcanada/poshBAR/blob/master/src/poshBAR/MSBuild.ps1#L63
Invoke-MSBuild "$($this.artifactsDir.output)\ClickOnce" `
        $this.solutions.uiShell `
        -target 'package' `
        -toolsVersion 4.0 `
        -maxCpuCount 8 `
        -VisualStudioVersion 12.0 `
        -logPath $this.artifactsDir.logs `
        -namespace 'TransCanada.MCA' `
        -customParameters @('/p:BootstrapperEnabled=true')

这是我的csproj文件(不包含依赖项)。

<?xml version="1.0" encoding="Windows-1252"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>9.0.30729</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{62B89443-7C08-4753-9C43-F53DABF7549D}</ProjectGuid>
    <OutputType>WinExe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>TransCanada.MCA.UI.Shell</RootNamespace>
    <AssemblyName>TransCanada.MCA.UI.Shell</AssemblyName>
    <SccProjectName>
    </SccProjectName>
    <SccLocalPath>
    </SccLocalPath>
    <SccAuxPath>
    </SccAuxPath>
    <SccProvider>
    </SccProvider>
    <StartupObject>TransCanada.MCA.UI.Shell.ShellApplication</StartupObject>
    <IsWebBootstrapper>true</IsWebBootstrapper>
    <ManifestCertificateThumbprint>98073FFOOBARBAZFIZZBUZZ19CD2F1A4</ManifestCertificateThumbprint>
    <ManifestKeyFile>
    </ManifestKeyFile>
    <GenerateManifests>true</GenerateManifests>
    <SignManifests>false</SignManifests>
    <TargetZone>LocalIntranet</TargetZone>
    <ApplicationIcon>Resources\MCAIcon.ico</ApplicationIcon>
    <FileUpgradeFlags>
    </FileUpgradeFlags>
    <OldToolsVersion>3.5</OldToolsVersion>
    <UpgradeBackupLocation>
    </UpgradeBackupLocation>
    <TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
    <TargetFrameworkProfile />
    <Install>true</Install>
    <InstallFrom>Web</InstallFrom>
    <UpdateEnabled>true</UpdateEnabled>
    <UpdateMode>Foreground</UpdateMode>
    <UpdateInterval>7</UpdateInterval>
    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
    <UpdatePeriodically>false</UpdatePeriodically>
    <UpdateRequired>false</UpdateRequired>
    <MapFileExtensions>true</MapFileExtensions>
    <InstallUrl>http://localhost/</InstallUrl>
    <TargetCulture>en</TargetCulture>
    <ProductName>MCA - Dev</ProductName>
    <PublisherName>TransCanada</PublisherName>
    <MinimumRequiredVersion>0.1.1.1</MinimumRequiredVersion>
    <CreateWebPageOnPublish>true</CreateWebPageOnPublish>
    <WebPage>publish.htm</WebPage>
    <ApplicationRevision>0</ApplicationRevision>
    <ApplicationVersion>0.1.1.1</ApplicationVersion>
    <UseApplicationTrust>false</UseApplicationTrust>
    <CreateDesktopShortcut>true</CreateDesktopShortcut>
    <PublishWizardCompleted>true</PublishWizardCompleted>
    <BootstrapperEnabled>true</BootstrapperEnabled>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
    <Prefer32Bit>false</Prefer32Bit>
    <CreateDesktopShortcut>true</CreateDesktopShortcut>
    <BootstrapperEnabled>true</BootstrapperEnabled>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>
    </DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
    <Prefer32Bit>false</Prefer32Bit>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <CreateDesktopShortcut>true</CreateDesktopShortcut>
    <BootstrapperEnabled>true</BootstrapperEnabled>
  </PropertyGroup>
  <PropertyGroup>
    <NoWin32Manifest>true</NoWin32Manifest>
  </PropertyGroup>

该解决方案还有一个customized.targets文件,但我不确定它是否会被提起。

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">

 <Target Name="UpdateCommonAssemblyInfo">
    <AssemblyInfo  
                    CodeLanguage="CS"
                    OutputFile="@(AssemblyInfoFiles)"
                   AssemblyVersion="$(VersionNum)"
                   AssemblyFileVersion="$(VersionNum)"
                   />
  </Target>


<PropertyGroup>
    <BuildEnvironment>Debug</BuildEnvironment>
</PropertyGroup>

<Choose>
    <When Condition=" '$(BuildEnvironment)' == 'Debug' ">
      <PropertyGroup>       
        <PublishDir>publish\$(BuildEnvironment)\</PublishDir>
      </PropertyGroup>
    </When>
    <When Condition=" '$(BuildEnvironment)' == 'Dev' ">
      <PropertyGroup>       
        <!--<PublishDir>publish\$(BuildEnvironment)\</PublishDir>-->
        <PublishDir>C:\inetpub\wwwroot\apps\MCA\Client\Azure\</PublishDir>
      </PropertyGroup>
    </When>
    <When Condition=" '$(BuildEnvironment)' == 'Azure' ">
      <PropertyGroup>
        <PublishDir>\\xxxxxxxxxxx\apps\MCA\client\$(BuildEnvironment)\</PublishDir>
      </PropertyGroup>
    </When>
    <When Condition=" '$(BuildEnvironment)' == 'Qual' ">
      <PropertyGroup>
        <PublishDir>\\xxxxxxxxxxx\cal\APPS\MCA\Client\$(BuildEnvironment)\</PublishDir>
      </PropertyGroup>
    </When>
    <When Condition=" '$(BuildEnvironment)' == 'Qual2MatrixProd' ">
      <PropertyGroup>
        <PublishDir>\\xxxxxxxxxxx\cal\APPS\MCA\Client\$(BuildEnvironment)\</PublishDir>
      </PropertyGroup>
    </When>
    <When Condition=" '$(BuildEnvironment)' == 'Prod' ">
      <PropertyGroup>
        <PublishDir>\\xxxxxxxxxxx\cal\APPS\MCA\Client\$(BuildEnvironment)\</PublishDir>
      </PropertyGroup>
    </When> 
</Choose>

<PropertyGroup>
        <!-- Note this must be done AFTER the above Choose (so PublishDir is set)-->
    <PublishFilePath>$(PublishDir)publish.html</PublishFilePath>
    </PropertyGroup>

<ItemGroup>
        <Tokens Include="PublisherName">
          <ReplacementValue>$(PublisherName)</ReplacementValue>
          <Visible>false</Visible>
        </Tokens>
        <Tokens Include="ProductName">
          <ReplacementValue>$(ProductName)</ReplacementValue>
          <Visible>false</Visible>
        </Tokens>
        <Tokens Include="ApplicationVersion">
          <ReplacementValue>$(ApplicationVersion)</ReplacementValue>
          <Visible>false</Visible>
        </Tokens>
        <Tokens Include="Prerequsites">
          <ReplacementValue>@(BootstrapperPackage->'&lt;li&gt;%(ProductName)&lt;/li&gt;','%0D%0A')</ReplacementValue>
          <Visible>false</Visible>
        </Tokens>
        <Tokens Include="Username">
          <ReplacementValue>$(Username)</ReplacementValue>
          <Visible>false</Visible>
        </Tokens>
    </ItemGroup> 
<!--<Target Name="AfterPublish">
    <Time Format="dd/MM/yyyy HH:mm">
        <Output TaskParameter="FormattedTime" PropertyName="PublishTime" />
    </Time>
    <TemplateFile Template="publish\publish.template.html" Tokens="@(Tokens)" OutputFilename="$(PublishFilePath)" />
    <FileUpdate Files="$(PublishFilePath)" Regex="\${PublishTime}" ReplacementText="$(PublishTime)" /> 
</Target> -->
</Project>

在生成引导程序时我缺少什么?

1 个答案:

答案 0 :(得分:1)

我只需通过Visual Studio发布为每个环境手动生成一个引导程序,然后完成。这有什么理由不起作用吗?

您需要重新生成引导程序的唯一原因是您的先决条件发生了变化,或者您的应用程序的部署URL是否发生了变化。两者似乎都非常罕见。