I have a Windows Forms application developed using C# in .NET framework 3.5, Service pack 1. The application can be published based on the development database as well as the production database. I am using MSBuild community tasks to publish my application. I do not face any problems while publishing the application to different location, namely a development location and a production location.
Issue:
After installing the development application into my machine, I am unable to install the production application. It gives me an error saying:
You cannot start application TEST from this location because it is already installed from a different location
Question: How does the machine understand that I am trying to install the same application? I assume it has some kind of an Application Id. If that's the case, I can override the concerned value based on the location. (DEV or PROD)
The current code while publishing in the project file of my application:
<Choose>
<When Condition=" '$(BuildEnvironment)' == 'DEV' ">
<PropertyGroup>
<PublishDir>\\A\B\development\</PublishDir>
<BaseConnection>Data Source=SQL-DEV.company.com; Database=TEST;Uid=XYZ;Pwd=ABC;</BaseConnection>
</PropertyGroup>
</When>
<When Condition=" '$(BuildEnvironment)' == 'PROD' ">
<PropertyGroup>
<PublishDir>\\A\B\production\</PublishDir>
<BaseConnection>Data Source=SQL-PROD.company.com;; Database=TEST;Uid=XYZ;Pwd=ABC;</BaseConnection>
</PropertyGroup>
</When>
</Choose>
The publishing of the application works like a charm and points to the concerned database. All I want to do now is be able to install the development application as well as production application on the same machine without any errors.
Question: What differentiates one click once application with the other?
The clickonce application is deployed to a company LAN network folder. The clickonce application is set to be available online or offline.
Windows Installer deployment requires administrative permissions and allows only limited user installation; ClickOnce deployment enables non-administrative users to install and grants only those Code Access Security permissions necessary for the application.
So I have finally figured out how to deploy different versions of the same application. The application manifest file was missing deploymentProvider attribute of the deployment element.
After adding deployment provider attribute of the deployment element in the application manifest, I was able to install my app from various location. But the problem here was that it was overriding the previously installed application. For this problem, I followed this tutorial to distinguish my development application from the production application.
Everything works great now. :)
I have a product called ClickOnceMore (www.clickoncemore.net) that is designed for this type of use. Its main use is in automating the ClickOnce part of your build.
It has full support for macro expansions allowing you to define, for example, DEV and PROD versions. When you build you can define which environment you are building for and then the App Name will reflect that. Check it out if you get a chance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With