在部署期间生成 setup.exe(引导程序)
Generating a setup.exe (bootstrapper) during deployment
我正在尝试自动部署 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->'<li>%(ProductName)</li>','%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>
生成引导程序时我缺少什么?
我会通过 Visual Studio 发布为每个环境手动生成引导程序,然后完成。这有什么不起作用的原因吗?
您需要重新生成引导程序的唯一原因是您的先决条件发生变化或者您的应用程序部署 url 发生变化。两者似乎都很少见。
我正在尝试自动部署 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->'<li>%(ProductName)</li>','%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>
生成引导程序时我缺少什么?
我会通过 Visual Studio 发布为每个环境手动生成引导程序,然后完成。这有什么不起作用的原因吗?
您需要重新生成引导程序的唯一原因是您的先决条件发生变化或者您的应用程序部署 url 发生变化。两者似乎都很少见。