app.config transformation and installation folder url - update location - visual-studio-2013

Is there a way to change the installation folder url and the update location of an application depending on the current configuration, in the same way you can change app.config properties with app.config transformations?

Related

Visual studio setup project: default installation location based on user choce

Is it possible to change the DefaultLocation proprty based on a user choice on a visual stuio 2013 setup project?
I have inserted a radio button dialog in User interface but I don't know how to use the selected button property to change the DefaultLocation propetry, if it is possible.
There already is a usr choice to specify the output directory. The user interface sequence has an InstallFolder dialog where you specify the Application Folder (as it's called in the File System view). That's the way the user browses to a location that is not the default of [ProgramFilesFolder][Manufacturer][ProductName] .
If you want to change the default location and base it on a search then this should work, assuming you have a registry entry defining the location:
Create a custom folder in the file system view, and give it a default location that's the same as the Application Folder setting, and an uppercase Property there called (for example) MYPATH. Put your files there, not Application Folder.
Add a registry search, in Search Target machine in launch conditions, and refer to the key and registry location, and with the Property MYPATH.
At install time the search will set the path to the value in the registry and install the files there.
The problem is that Visual Studio setup projects don't offer all the capabilities of Windows Installer, although other tools do. With other tools you could run code to set the location, just as an example.

Modifying web.config for development and production environments

I have a webApi project and after deployment to Dev environment I need to edit web.config and change connection to database from production configuration to development configuration and back if I need deployment to prod.
How can I automatically set webconfig for selected dev or prod in the release or debug I use in my project?
To specify the changes that you want to make in Web.config files, you use transform files. A transform file is associated with a build configuration.
If you want to create a transform file for a custom build configuration that does not exist, create the build configuration first by using Configuration Manager.
You can open Configuration Manager by selecting it from the Build menu.
In Solution Explorer, expand the application Web.config file.
If any transform files have already been created, the Web.config file is displayed in Solution Explorer with a symbol indicating that it can be expanded, and the transform files are shown when you expand the Web.config file.
The build configuration that a transform is for is indicated by a string in the file name. For example, a transform file for the Debug build configuration is named Web.Debug.config.
If no transform file exists for the build configuration that you want to specify settings for, in Solution Explorer, right-click the Web.config file and then click Add Config Transforms.
Open the transform file for the build configuration that you want to work with.
Edit the transform file to specify the changes that should be made to the deployed Web.config file when you deploy by using that build configuration.
The default transform file includes comments that show how to code some common transforms.
The following example shows how to use the Match locator and the SetAttributes transform attribute. The Match locator attribute identifies the add element in the connectionStrings section as the element to change. The SetAttributes transform attribute specifies that this element's connectionString attribute should be changed to "ReleaseSQLServer".
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="MyDB"
connectionString="ReleaseSQLServer"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
</configuration>
Save and close the transform file.
When you deploy the Web application by using the selected build configuration and by using either a deployment package or one-click publish, the Web.config file is transformed according to your specifications.

Multiple build configuration in Advanced Installer

I am using Advanced Installer with Visual Studio 2010.
I managed to create an .aip project, but when I want to add the files from the relevant VS projects, I have to choose the exact location of these files.
I want to use more then one build configuration so I can use config transforms to change my .config files depend on the build configuration I choose.
This is a problem for me because when I compile in Debug the .exe & .dll files goes to bin\Debug, but when I compile in, lets say, Staging these files goes to bin\Staging.
How can I get Advanced Installer to get the right files, meaning get them from the target folder of the build configuration I chosen?
Advanced Installer does not support this by default, but with a little bit of tweaking you can get this working. Let me explain how:
the first requirement is to have your output folders generated by VS in the same parent folder, as you have them both placed in "bin\".
now you need to open your project in Advanced Installer GUI and do the following:
create two builds in Media page, called Debug and Staging
create a property called "Configuration" or what name would you like, from Install Parameters page
in the New Property dialog you will have options to set per-build values for your property. Set them to "Debug" and "Staging", i.e. the names of the folders created by VS
now go to File -> Options -> Path Variables and define a new path variable with your full path for the debug/staging, the one you current have in the project.
from the Home tab, in the toolbar, use the "Convert Paths" wizard and then save the project.
Now, it comes the tricky part, you will need to edit the project file in a text editor, like Notepad++, capable of saving the file in UTF-8 format. Once you open the file look for this XML node:
<COMPONENT cid="caphyon.advinst.msicomp.AppPathsComponent">
<ROW Name="BIN_DIR" Path="<your path>\bin\Debug" Type="2" Content="0"/>
You might have multiple variables here if you are already using this feature. You need to edit the value and replace "Debug" with "[|Configuration]".
Now you can save and build the project and it should pickup the correct files for each of the two builds.

Specifying a file location in a Unit Test with Visual Studio tests

I have a set of text files that I need to have a test take in and use the items for specific parts of some Unit tests I am writing. I have put a file path in my app.config of just: .\DataLists\
After I put that in there I added the items needed to add a custom section so it would then get that file path information. The problem I am having is this...it is not finding those lists in that location it is looking at some tmp folder instead. How do I specify a proper file location for this?
Have you tried using the DeploymentItemAttribute? link Use this on the test method(s) where you need access to your 'set' (folder I assume) of text files. The best practice here is to add the folder and files you want deployed to your project file and set them to 'Copy if newer' or 'Copy Always'.
You can also add the file(s) or folder to the Deployment section of the .testsettings configuration screen. In my experience this works better during Team Builds than the DeploymentItemAttribute route. In either case the 'Enable deployment' check box found in the .testsettings config screen must be checked.

How do I set the start URL of a Visual Studio project globally?

I need to change the start URL of a project. When I set the start URL on the property page, it gets written to the csproj.user file and not the csproj. I tried putting the <StartExternalURL> in the csproj in the <WebProjectProperties> section, but that did not work.
Is there any way I can set that property and propagate it to the entire team, or is everyone just going to have to make the change manually?
You should add the csproj.user file under source control. When everyone checks it out, their start URL will be set correctly.

Resources