views:

202

answers:

2

I'm currently looking at ClickOnce deployment for our WPF application and was wondering, is it possible to set the ProductName and PublishUrl separately for each build configuration in the project file?

At the moment I'm having to set these manually in the Publish options, but it could be easy for someone to forget to do this and end up publishing a Test version of our application to our Training environment or vice versa.

I know that I also have to change the Application Identity using MageUI in order to run multiple versions of the ClickOnce application on the same PC, but it would be nice to at least not have to worry about the ProductName and PublishUrl properties being correct every time we need to do a deployment (although it would be ideal if we could access the Application Identity from within the IDE too!).

+1  A: 

This might be a very similar question to http://stackoverflow.com/questions/1754318/how-do-i-deploy-two-clickonce-versions-simultaneously, which I answered as follows:

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).

This means that each exe project can have it's own clickonce publishing settings, as well as it's own app.config file. This means you have have different connection strings for the production and the test version.

If your situation is different to that other guy, let us know

Cheers - Rob

Rob Fonseca-Ensor
I never thought of that, it sounds like a bit of a hack, but if it works it works I suppose! We don't have an issue with the app.config files, those are specified for each configuration from within the project file... <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Test|AnyCPU' "> <AppConfig>app.Test.config</AppConfig> </PropertyGroup>I tried putting the ProductName and PublishUrl properties in here too, but it didn't seem to have any effect.
TabbyCool
A: 

It turns out that you can set the PublishUrl and ProductName in the .csproj file for each configuration setting, but you need to close and reopen the solution file before the project properties are refreshed, merely unloading and reloading the project or building it under a different configuration isn't enough to refresh this, it would seem.

My csproj file now has the following settings for each configuration...

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Test|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <AppConfig>app.Test.config</AppConfig>
    <PublishUrl>http://MyServer/Synergi/Test/&lt;/PublishUrl&gt;
    <ProductName>Synergi Test</ProductName>
</PropertyGroup>
TabbyCool