How do I deploy two ClickOnce versions simultaneously?

∥☆過路亽.° 提交于 2019-11-27 18:21:47
Rob Fonseca-Ensor

It might sound kind of lame, but the easiest way to do this is to have two EXE projects in your solution. The Main method of each of these will just call the Main method in your original EXE project (which you'll have just switched over to being a DLL file).

This means that each EXE project can have its own ClickOnce publishing settings, as well as its own app.config file. This means you have different connection strings for the production and the test version.

Your other option (the one that might seem to make the most sense) is to use MageUI.exe to manually build the ClickOnce files, which would let you choose a different configuration file and publish location each time you ran the tool. There's also a command line version (Mage.exe) so you could in theory automate this.

However, we found that the solution with two "runner" projects was far far simpler. I'd recommend you try that first.

RobinDotNet

ClickOnce: Concurrent versions explains how to do this.

LongZheng

I manually edited the .csproj to specify a different ProductName for debug/release.

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    ...
    <PublishUrl>publishbeta\</PublishUrl>
    <InstallUrl>http://www.softwareabc.com/download/beta/</InstallUrl>
    <ProductName>Software ABC Test</ProductName>
    <AssemblyName>SoftABCTest</AssemblyName>
    <ApplicationIcon>Resources\Test.ico</ApplicationIcon>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    ...
    <PublishUrl>publish\</PublishUrl>
    <InstallUrl>http://www.softwareabc.com/download/</InstallUrl>
    <ProductName>Software ABC</ProductName>
    <AssemblyName>SoftABC</AssemblyName>
    <ApplicationIcon>Resources\Application.ico</ApplicationIcon>
</PropertyGroup>

One caveat is that Visual Studio 2010 doesn't update this if you switch between debug/release. It only takes effect when it loads the solution so make sure to switch debug/release then close and reopen the solution.

dgp

See the succinct video on concurrent versioning: ClickOnce: Concurrent versions.

Try changing the Assembly Name in the Application tab in the properties window.

You have to edit your csproj manually, after having at least once configured your project to publish a Click Once application.

Move some of Click Once related properties from the <PropertyGroup> to the <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> property group and duplicate them under the <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> property group.

The properties to duplicate are ApplicationRevision (only if you want separate revision counters), PublishUrl, ProductName and SuiteName (the last two are required to be able to differentiate the configurations on the target machines). You also will have to override the AssemblyName property (without removing it from the first group).

If you want to be able to debug your project under any configuration, you also will have to add the StartAction and StartProgram properties in each group where you overrode the AssemblyName property.

After having given these properties adequate (i.e. different) values, you will be able to publish both configurations, without having to modify your project, just by selecting the desired configuration. Note however you will have to unload your project between publishes for different configurations, or Visual Studio will mess up your parameters.

After that, you also will be able to install both versions on the same target machine.

Jonathan Allen

I do that all the time. I even have a screen in my application that changes which version a specific user will get. And I'm not doing anything tricky on the app side, all the magic is on the web server hosting the ClickOnce files.

Take a look at the article my buddy wrote, Fine Grained Versioning with ClickOnce . It explains how we did it.

A variation on Peter Mortensen's two project scenario. I wanted dev, customer test, and customer release. In my case I wanted the customer test providing some visual clues that it was test, not live (e.g. 'TEST' in the title and a different visual theme).

I found it simplest to have two solutions as well as two stub projects. Each project in its own directory, with its own stub program.cs, app.config and assemblyinfo.cs.

In the dev/test solution, the debug configuration was for dev, the release config was for customer test. I used SlowCheetah to transform the app.config for the latter.

In the customer release solution I needed only a release config.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!