8

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

TabbyCool
  • 2,829
  • 1
  • 24
  • 36

1 Answers1

11

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/</PublishUrl>
    <ProductName>Synergi Test</ProductName>
</PropertyGroup>
TabbyCool
  • 2,829
  • 1
  • 24
  • 36
  • When I try this approach my PropertyGroup PublishUrl and ProductName actually get overwritten by whatever options are loaded first. Very annoying. I really need a way to automate this. – kbeal2k Aug 31 '12 at 18:05
  • in my experience, if you manually modify the nodes inside the csproj file, Visual Studio will be confused, but msbuild itself will behave as expected. I think that if had looked at the compiled binaries, you would have seen that, even though Visual Studio shows no difference, the binaries' properties are different between both versions. – DonkeyMaster Jul 09 '13 at 12:47
  • 2
    The problem is that if you update anything on the project's property tab in VS the options in proj file gets overwritten so it would require manual check before each deployment if the install and update urls are correct in the proj file. And the manual work is something you try to avoid here. I didn't find any solution for it yet. – Chris W. Jun 29 '15 at 08:48