Windows Installer Visual Studio Setup Project - c#

How can I change DefaultLocation value of the Application Folder (or Custom Folder) in code?
I can define DefaultLocatio as [MY_DEFAULT] on the File System in Visual Studio, add to CustomActionData /myDefault=[MY_DEFAULT] and pass MY_DEFAULT as parameter to the msi file.
In code I can read it as Context.Parameters["myDefault"]. This works.
But how can i change in code the value of the DefaultLocation where the application will be installed?

Right-click your Installer project, go to View->File System.
Now right-click on the 'Application Folder' and select 'Properties Window'. In the Properties Window you can edit the DefaultLocation field (see screenshot below).
By default, the DefaultLocation is [ProgramFilesFolder][Manufacturer]\[ProductName] but you can change it to anything you like - C:\MyApp\ or [ProgramFilesFolder]MyApp\ or whatever.
Good Luck.

Related

Create shortcut in Visual studio project

Problem:
I have a visual studio solution with a visual studio setup project.
During the installation of the msi package, I want a shortcut to be created in the startup folder, so that my application can automatically start when the user logs in.
Action Taken:
I followed this :
How to create an installer project in VS2019 for a Windows form application
and this
Visual Studio Deployment Project - Create shortcut to deployed executable
This question must not be considered as duplicate as these steps are not working for me, they endup with a corrupted shortcut. The shortcut gets created but is not working:
The application deploys correctly and the link gets created but it does not point to the executable.
If you look at the picture below, you'll see That Target is greyed out and "points" to a folder. It should mention the executable name.
If I create a shortcut manually, you can see the difference (Target is properly filled)
Steps to reproduce:
Right click setup then view File System
Right click File System on Target Machine, then Add Special Folder / User's Startup folder
On the right panel of Application Folder, I right click Primary Output of FormAgent and Create Shortcut to Primary Output
I drag and drop the shortcut to User's Startup Folder and rename it appropriately.
Result: Shortcut gets created in the startup folder but is corrupted.
Troubleshooting done:
I wanted to create a shortcut to FormAgent.exe instead of a shortcut to Primary Output. But nowhere in the GUI I found a place to select anything else than Primary Output. Every single GUI is proposing Primary output from ProjectName and nothing else.
See the below picture which is the Properties of the shortcut: In the properties, if I click on Target, it points to Primary Output with no possibility to select an executable. (Add File is adding an external file to the setup project).
As additional troubleshooting, I went back to Application Folder and edited the properties of Primary Output, then clicked on Output:
The output displays 2 files and I wonder if this could be the cause of my problem. ( What is a result of a shortcut to an output that has 2 files?)

How can I get the Product Name in a Visual Studio post build event?

I'm setting up a post build event to copy the DLL compiled by Visual Studio into my Unity project, but I can't get it to use the Product Name in the destination path. My command looks like this:
cd $(ProjectDir)
echo F|xcopy /Y "bin\release\$(AssemblyName).dll" "..\..\..\Assets\Plugins\$(ProductName)\$(AssemblyName).dll"
But that puts the file straight in the Plugins directory.
I can use $(RootNamespace) for some projects, but that won't work if I want a space in the folder name.
I know I could just put the product name in manually for each project, but is there a way to get Visual Studio to do it automatically like with the assembly name?
For C/C++ projects,
Use the Property Manager (in the menu bar: View/Other Windows/Property Manager) to manage your projects' properties.
You can define a custom marco like $(ProjectName) in a new property sheet. And share the property sheet among your projects. Then you can use the marco in the post build event of every project.
For C# projects,
Use the Property Functions.
In Visual Studio 2012 (C#) How to Create Custom Macros available in Post Build
MSBuild: Permanently Change PropertyGroup Property of a Project
By the way, you can use the environment variables if it is good for you.

"User's Application Data Folder"; Is it possible to force between SpecialFolder.ApplicationData and SpecialFolder.LocalApplicationData

I have an application that needs to run at normal privileges. So it gets installed in Environment.SpecialFolder.ProgramFiles, but stores conf/logging/history details in Environment.SpecialFolder.LocalApplicationData.
The problem is that in the Setup/Deploy project, in the File System section I don't get to distinguish between ApplicationData (roaming) or LocalApplicationData, only "User's Application Data Folder," which could be either depending who installs it on what machine.
Is it possible to force "User's Application Data" to be one or the other?
MSI does support local application data folder. If you're talking about a Setup and Deployment project, maybe switching to another installer framework like WiX might be in order. (Setup and Deployment no longer exists in Visual Studio 2012 anyway). WiX has a tool called Dark that will convert an MSI to WiX XML files so you can simply edit them or add to them quickly and easily.
The Setup Project has made a comeback in visual Studio 2015.
The following works with VS 2015:
In file system view, add a special folder of type 'Custom'.
In the properties of this folder, set the following values:
Name : Local App data folder
AlwaysCreate : True
Condition : (leave empty)
DefaultLocation : [LocalAppDataFolder]
Property : SOMEPROPERTYNAME
The magic happen thanks to DefaultLocation property value: [LocalAppDataFolder].
I suppose any system folder variable as defined in the following link should work:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa370905(v=vs.85).aspx#system_folder_properties

Unable to access 'Build Action' property for .cs files

i got a problem with my site with my app_code files and a lot of question ive read people say you need to change the proprties of the .cs files to Build Action.
by right clicking the .cs files and press proprties.
but...
when i right clicking the files i cant see any option called proprties so i press F4 and it open a proprties window and i just click on the .cs file and still cant see any option i can change somthing to Build Action.
any idea why i cant see this options?
EDIT:
my problem is that when i get in the file proprties i have only 2 options...
thay are called:
1.Full Name
2.Full Path
EDIT2:
here what i see in visual studio 2010 when i try access the protrtie menu/window
http://img338.imageshack.us/img338/2359/blac.png
As Microsoft points out in the article "Web Application Projects versus Web Site Projects":
Web application projects use Visual Studio project files (.csproj or
.vbproj) to keep track of information about the project. Among other
tasks, this makes it possible to specify which files are included in
or excluded from the project, and therefore which files are compiled
during a build.
An answer to a similiar question at CodeProject's forums reveals a hint. Abstract:
[...] Looks like you are working on a web application that is actually a
Website as per Visual Studio. You would need to create a new Web Application
and probably copy over the source files there. [...]
http://www.codeproject.com/Questions/173637/Setting-Build-Action-for-Files-in-App_Data
Have you tried this:
You say you haven't got the option being suggested by other posters.
If this is the case, than it is quite possible that your Visual Studio settings are corrupt; this can give rise to all sorts of odd behaviour.
I would suggest you reset your settings, but please be aware you will lose any custom IDE settings that you've previously applied.
Try this:
In Visual Studio, go to Tools->Import and Export Settings
Choose "Reset All Settings" and click Next
Choose to save your current settings if you wish, or select "no" and then click next.
Choose the collection of settings( he IDE preset) you want, probably "Visual C# Development Settings"
Visual Studio will now revert all settings. Hopefully this will make the Build Action reappear.
[EDIT]
It might be worth trying safe mode too.
To do this, start up a "Visual Studio Command Prompt" from your start menu/programs list in Windows, and start Visual Studio with
devenv.exe /SafeMode
Does this make the options appear?
You can copy the file from Windows Explorer and paste it in the Solution Explorer. It will replace (or do nothing but incorporating it in the proj file) the file and recognize it as C#.
Normally you should see a Property named "Build Action" in the first line of the Property Window. This property should be set to "Compile".
Please select file and right click on it so that you will get following screen
Than click on the Properties you will get following screen
You can find build option in as a first option.

Add common Startup Folder to VS2008 Setup Solution

When you right click the File System on Target Machine tree and select Add Special Folder inside a setup application you get a list of options. One is User's Startup Folder....however there is no option for Common/All Startup Folder. Is there a way to specify the common/all startup folder as a custom folder and still have it work properly in XP, Vista, and Win7?
Select the Deployment Project Properties and set the InstallAllUsers option to True.
Here is a little microsoft walk-through:
http://msdn.microsoft.com/en-US/library/716bxh4e(v=vs.80).aspx
You will also need to set the InstallAllUsers to TRUE and replace the '[TempFolder]' from the example with '[StartupFolder]'

Categories

Resources