使用 Msbuild 更改 setup.exe 的 url(部署 ClickOnce)

发布于 2024-08-20 11:34:28 字数 823 浏览 8 评论 0 原文

我使用 msbuild 来使用 setup -url="location"...

我使用 ClickOnce 发布应用程序,并且我想更改 setup.exe 中的 url。

<Exec Command="$(PublishDir)\setup -url=$(ProviderUrl)" />

另一个问题是,使用 /url 开关更改 URL 后,会出现手动确认签名对于程序集无效的消息。

两个问题:

  1. 如何在静默模式下使用 setup -url=http://.... ?我不希望出现确认消息。

  2. 如何对setup.exe再次签名?

有什么解决办法吗?谢谢先生

我的 msbuild

<Target Name="PublishClickOnce">

<Exec Command="$(PublishDir)\setup -url=$(ProviderUrl)" /> 

<Exec Command="$(Mage) -u $(PublishDir)\Frk.Security.CarWin.application -pu $(ProviderUrl)" /> 

<Exec Command="$(Mage) -u $(PublishDir)\Frk.Security.CarWin.application -cf $(CertDir)\Frk.Security.CarWin_TemporaryKey.pfx" /> 

 </Target>

有什么帮助吗?提前致谢。

I use msbuild for using setup -url="location"...

I publish application using ClickOnce and I want changes the url in the setup.exe.

<Exec Command="$(PublishDir)\setup -url=$(ProviderUrl)" />

Another problem is that after using the /url switch to change out the URL, it appears message for manually confirming that the signature will be invalided for the assembly.

two issues:

  1. how can use setup -url=http://.... in mode silent ?? I dont want that appears the message for confirming.

  2. How can signature the setup.exe again ??

any solution about it ?? Thanks mister

My msbuild

<Target Name="PublishClickOnce">

<Exec Command="$(PublishDir)\setup -url=$(ProviderUrl)" /> 

<Exec Command="$(Mage) -u $(PublishDir)\Frk.Security.CarWin.application -pu $(ProviderUrl)" /> 

<Exec Command="$(Mage) -u $(PublishDir)\Frk.Security.CarWin.application -cf $(CertDir)\Frk.Security.CarWin_TemporaryKey.pfx" /> 

 </Target>

Any help, please? Thanks in advance.

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

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

发布评论

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

评论(2

稚气少女 2024-08-27 11:34:28

这就是我们如何使用 TeamBuild 为多种环境构建 ClickOnce 应用程序。

您可以阅读我的原始博文 此处

这是从 TeamBuild 项目文件调用 ClickOnce 构建的方式(添加换行符以提高可读性):

<Msbuild
      Projects="$(SolutionRoot)\ConfigFiles\BuildClickOnce.targets"
      Targets="BuildClickOnce"
      Properties="SourceDir=$(SourceDir);PublishDir=$(PublishDir);                      ClickOnceAppName=$(ClickOnceAppName);ClickOnceExeFile=$(ClickOnceExeFile);                      ClickOnceProduct=$(ClickOnceProduct);Company=$(Company);                      ClickOnceDescription=$(ClickOnceDescription);ClickOnceUrl=$(ClickOnceUrl);                      VersionNumber=$(VersionNumber);SigningCert=$(SigningCert);                      SigningCertPassword=$(SigningCertPassword)"
        />

对于您想要的每个环境或配置更改你用这个。您可以在下面找到 BuildClickOnce.targets 文件(为了便于阅读而添加换行符):

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets" />
    <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
    <Import Project="$(MSBuildExtensionsPath)\Microsoft\SDC\Microsoft.Sdc.Common.tasks"/>


    <Target Name="BuildClickOnce" DependsOnTargets="">

        <PropertyGroup>      
            <ClickOnceApplicationUrl>$(ClickOnceUrl)$(ClickOnceAppName).application</ClickOnceApplicationUrl>
            <AppPublishDir>$(PublishDir)</AppPublishDir>
            <SdkPath>C:\Program Files\Microsoft SDKs\Windows\v6.0A</SdkPath>
        </PropertyGroup>

        <BuildStep
          TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
          BuildUri="$(BuildUri)"
          Message="Buildning $(ClickOnceAppName) ClickOnce version: $(VersionNumber)">
            <Output TaskParameter="Id" PropertyName="StepId" />
        </BuildStep>


    <CallTarget Targets="UpdateWebPage" />

        <!--
  ************************************************
  Generate application manifest
  ************************************************
  -->
        <Exec
        Command="mage.exe -New Application -TrustLevel FullTrust                  -ToFile "$(AppPublishDir)\$(ClickOnceExeFile).manifest"                  -Name "$(ClickOnceAppName)" -Version "$(VersionNumber)"                 -FromDirectory "$(AppPublishDir)""
        WorkingDirectory="$(SdkPath)\Bin"/>

        <!--
  ************************************************
  Signing application manifest
  ************************************************
  -->
        <Exec Condition="'$(SigningCertPassword)'==''"
          Command="mage.exe -Sign "$(AppPublishDir)\$(ClickOnceExeFile).manifest"                    -CertFile "$(SigningCert)""
          WorkingDirectory="$(SdkPath)\Bin"  />

        <Exec Condition="'$(SigningCertPassword)'!=''"
            Command="mage.exe -Sign "$(AppPublishDir)\$(ClickOnceExeFile).manifest"                      -CertFile "$(SigningCert)" -Password "$(SigningCertPassword)""
            WorkingDirectory="$(SdkPath)\Bin"/>

        <!--
  ************************************************
  Renaming source files to .deploy
  ************************************************
  -->
        <ItemGroup>
            <SourceFilesToRename Include="$(AppPublishDir)\**\*.*"                  Exclude="$(AppPublishDir)\*.manifest;$(AppPublishDir)\*.htm"/>
            <SourceFilesToDelete Include="$(AppPublishDir)\**\*.*"                  Exclude="$(AppPublishDir)\*.application;$(AppPublishDir)\*.manifest;$(AppPublishDir)\*.htm"/>
        </ItemGroup>

        <Copy
            SourceFiles="@(SourceFilesToRename)"
            DestinationFiles="@(SourceFilesToRename->'$(AppPublishDir)\%(RecursiveDir)%(Filename)%(Extension).deploy')"
        />

        <Delete Files="@(SourceFilesToDelete)"/>


        <!--
  ************************************************
  Generating deployment manifest
  ************************************************
  -->

        <GenerateDeploymentManifest
          MapFileExtensions="true"
          AssemblyName="$(ClickOnceAppName).application"
          AssemblyVersion="$(VersionNumber)"
          MinimumRequiredVersion="$(VersionNumber)"
          DeploymentUrl="$(ClickOnceApplicationUrl)"
          Description="$(ClickOnceDescription)"
          Product="$(ClickOnceProduct)"
          Publisher="$(Company)"
          SupportUrl="$(SupportUrl)"
          EntryPoint="$(AppPublishDir)\$(ClickOnceExeFile).manifest"
          Install="true"
          UpdateEnabled="true"
          UpdateMode="Foreground"
          OutputManifest="$(PublishDir)\$(ClickOnceAppName).application"/>

        <!--
  ************************************************
  Signing application manifest
  ************************************************
  -->
        <Exec Condition="'$(SigningCertPassword)'==''"
            Command="mage.exe -Sign "$(PublishDir)\$(ClickOnceAppName).application"                     -CertFile "$(SigningCert)""
            WorkingDirectory="$(SdkPath)\bin"/>
        <Exec Condition="'$(SigningCertPassword)'!=''"
            Command="mage.exe -Sign "$(PublishDir)\$(ClickOnceAppName).application"                     -CertFile "$(SigningCert)" -Password "$(SigningCertPassword)""
            WorkingDirectory="$(SdkPath)\bin"/>


        <!--
  ************************************************
  Generating Bootstrapper
  ************************************************
  -->
        <ItemGroup>
            <BootstrapperFile Include="Microsoft.Net.Framework.2.0">
                <ProductName>Microsoft .NET Framework 2.0</ProductName>
            </BootstrapperFile>
        </ItemGroup>


        <GenerateBootstrapper
          ApplicationFile="$(ClickOnceAppName).application"
          ApplicationName="$(ClickOnceAppName)"
          ApplicationUrl="$(ClickOnceUrl)"
          BootstrapperItems="@(BootstrapperFile)"
          Culture="en"
          FallbackCulture="en-US"
          CopyComponents="true"
          Validate="false"
          Path="$(SdkPath)\Bootstrapper"
          OutputPath="$(PublishDir)"/>


        <BuildStep
          TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
          BuildUri="$(BuildUri)"
          Id="$(StepId)"
          Status="Succeeded"/>

        <OnError ExecuteTargets="MarkBuildStepAsFailed" />
    </Target>

    <!--
  ************************************************
  Marks a buildstep as failed
  ************************************************
  -->
    <Target Name="MarkBuildStepAsFailed">
        <BuildStep
          TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
          BuildUri="$(BuildUri)"
          Id="$(StepId)"
          Status="Failed"/>
    </Target>

    <!--
  ************************************************
  Updating web page
  ************************************************
  -->
    <Target Name="UpdateWebPage">
        <ItemGroup>
            <WebPage Include="$(PublishDir)\publish.htm" />
        </ItemGroup>

        <RegEx
          Condition="Exists(@(WebPage))"
          Path="@(WebPage)"
          RegularExpression="#VERSION#"
          NewValue="$(VersionNumber)"
          Force="true"/>
    </Target>
</Project>

This how we build ClickOnce applications with TeamBuild for multiple environments

You can read my original blogpost here

This is how you call the ClickOnce build from you TeamBuild project file (line breaks added for readability):

<Msbuild
      Projects="$(SolutionRoot)\ConfigFiles\BuildClickOnce.targets"
      Targets="BuildClickOnce"
      Properties="SourceDir=$(SourceDir);PublishDir=$(PublishDir);                      ClickOnceAppName=$(ClickOnceAppName);ClickOnceExeFile=$(ClickOnceExeFile);                      ClickOnceProduct=$(ClickOnceProduct);Company=$(Company);                      ClickOnceDescription=$(ClickOnceDescription);ClickOnceUrl=$(ClickOnceUrl);                      VersionNumber=$(VersionNumber);SigningCert=$(SigningCert);                      SigningCertPassword=$(SigningCertPassword)"
        />

For every environment or configuration change you want you use this. Below you find the BuildClickOnce.targets file (line breaks added for readability):

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets" />
    <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
    <Import Project="$(MSBuildExtensionsPath)\Microsoft\SDC\Microsoft.Sdc.Common.tasks"/>


    <Target Name="BuildClickOnce" DependsOnTargets="">

        <PropertyGroup>      
            <ClickOnceApplicationUrl>$(ClickOnceUrl)$(ClickOnceAppName).application</ClickOnceApplicationUrl>
            <AppPublishDir>$(PublishDir)</AppPublishDir>
            <SdkPath>C:\Program Files\Microsoft SDKs\Windows\v6.0A</SdkPath>
        </PropertyGroup>

        <BuildStep
          TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
          BuildUri="$(BuildUri)"
          Message="Buildning $(ClickOnceAppName) ClickOnce version: $(VersionNumber)">
            <Output TaskParameter="Id" PropertyName="StepId" />
        </BuildStep>


    <CallTarget Targets="UpdateWebPage" />

        <!--
  ************************************************
  Generate application manifest
  ************************************************
  -->
        <Exec
        Command="mage.exe -New Application -TrustLevel FullTrust                  -ToFile "$(AppPublishDir)\$(ClickOnceExeFile).manifest"                  -Name "$(ClickOnceAppName)" -Version "$(VersionNumber)"                 -FromDirectory "$(AppPublishDir)""
        WorkingDirectory="$(SdkPath)\Bin"/>

        <!--
  ************************************************
  Signing application manifest
  ************************************************
  -->
        <Exec Condition="'$(SigningCertPassword)'==''"
          Command="mage.exe -Sign "$(AppPublishDir)\$(ClickOnceExeFile).manifest"                    -CertFile "$(SigningCert)""
          WorkingDirectory="$(SdkPath)\Bin"  />

        <Exec Condition="'$(SigningCertPassword)'!=''"
            Command="mage.exe -Sign "$(AppPublishDir)\$(ClickOnceExeFile).manifest"                      -CertFile "$(SigningCert)" -Password "$(SigningCertPassword)""
            WorkingDirectory="$(SdkPath)\Bin"/>

        <!--
  ************************************************
  Renaming source files to .deploy
  ************************************************
  -->
        <ItemGroup>
            <SourceFilesToRename Include="$(AppPublishDir)\**\*.*"                  Exclude="$(AppPublishDir)\*.manifest;$(AppPublishDir)\*.htm"/>
            <SourceFilesToDelete Include="$(AppPublishDir)\**\*.*"                  Exclude="$(AppPublishDir)\*.application;$(AppPublishDir)\*.manifest;$(AppPublishDir)\*.htm"/>
        </ItemGroup>

        <Copy
            SourceFiles="@(SourceFilesToRename)"
            DestinationFiles="@(SourceFilesToRename->'$(AppPublishDir)\%(RecursiveDir)%(Filename)%(Extension).deploy')"
        />

        <Delete Files="@(SourceFilesToDelete)"/>


        <!--
  ************************************************
  Generating deployment manifest
  ************************************************
  -->

        <GenerateDeploymentManifest
          MapFileExtensions="true"
          AssemblyName="$(ClickOnceAppName).application"
          AssemblyVersion="$(VersionNumber)"
          MinimumRequiredVersion="$(VersionNumber)"
          DeploymentUrl="$(ClickOnceApplicationUrl)"
          Description="$(ClickOnceDescription)"
          Product="$(ClickOnceProduct)"
          Publisher="$(Company)"
          SupportUrl="$(SupportUrl)"
          EntryPoint="$(AppPublishDir)\$(ClickOnceExeFile).manifest"
          Install="true"
          UpdateEnabled="true"
          UpdateMode="Foreground"
          OutputManifest="$(PublishDir)\$(ClickOnceAppName).application"/>

        <!--
  ************************************************
  Signing application manifest
  ************************************************
  -->
        <Exec Condition="'$(SigningCertPassword)'==''"
            Command="mage.exe -Sign "$(PublishDir)\$(ClickOnceAppName).application"                     -CertFile "$(SigningCert)""
            WorkingDirectory="$(SdkPath)\bin"/>
        <Exec Condition="'$(SigningCertPassword)'!=''"
            Command="mage.exe -Sign "$(PublishDir)\$(ClickOnceAppName).application"                     -CertFile "$(SigningCert)" -Password "$(SigningCertPassword)""
            WorkingDirectory="$(SdkPath)\bin"/>


        <!--
  ************************************************
  Generating Bootstrapper
  ************************************************
  -->
        <ItemGroup>
            <BootstrapperFile Include="Microsoft.Net.Framework.2.0">
                <ProductName>Microsoft .NET Framework 2.0</ProductName>
            </BootstrapperFile>
        </ItemGroup>


        <GenerateBootstrapper
          ApplicationFile="$(ClickOnceAppName).application"
          ApplicationName="$(ClickOnceAppName)"
          ApplicationUrl="$(ClickOnceUrl)"
          BootstrapperItems="@(BootstrapperFile)"
          Culture="en"
          FallbackCulture="en-US"
          CopyComponents="true"
          Validate="false"
          Path="$(SdkPath)\Bootstrapper"
          OutputPath="$(PublishDir)"/>


        <BuildStep
          TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
          BuildUri="$(BuildUri)"
          Id="$(StepId)"
          Status="Succeeded"/>

        <OnError ExecuteTargets="MarkBuildStepAsFailed" />
    </Target>

    <!--
  ************************************************
  Marks a buildstep as failed
  ************************************************
  -->
    <Target Name="MarkBuildStepAsFailed">
        <BuildStep
          TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
          BuildUri="$(BuildUri)"
          Id="$(StepId)"
          Status="Failed"/>
    </Target>

    <!--
  ************************************************
  Updating web page
  ************************************************
  -->
    <Target Name="UpdateWebPage">
        <ItemGroup>
            <WebPage Include="$(PublishDir)\publish.htm" />
        </ItemGroup>

        <RegEx
          Condition="Exists(@(WebPage))"
          Path="@(WebPage)"
          RegularExpression="#VERSION#"
          NewValue="$(VersionNumber)"
          Force="true"/>
    </Target>
</Project>
独夜无伴 2024-08-27 11:34:28

如果您想更改 url,最好这样做:

  1. 编辑 .application 并替换部署提供程序中的 url
  2. 使用 GenerateBootstrapper 来构建新的 setup.exe
  3. 签名应用程序和设置,

我发现使用 -url 参数使设置在签名后无效

If you want to change the url you're better off doing:

  1. Edit the .application and replace the url in the deploymentProvider
  2. Use GenerateBootstrapper from to build a new setup.exe
  3. Sign application and setup

I found using the -url parameter made the setup invalid after I signed it

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