I have two different windows application projects. I want that at the time of installation both will install together in same folder like one exe is installed.After installation both will work separately.There is an xml file which will be update by one project which have forms and another exe will use it which does not contain any form,just show the notify icon.Is it possible to create a setup file which will install both the exe's together? how do I give the path of the xml file?
You can use SetupProject to do it
Add setup project:
http://msdn.microsoft.com/en-us/library/19x10e5c(v=vs.80).aspx
Add primary outputs of both applications to it
http://msdn.microsoft.com/en-us/library/z11b431t(v=vs.80).aspx
If you want to place your xml file in your installation folder, there are permission issues to resolve if you want to change it later when your applications are running (usually admin privilages are needed), so you can't just add it to your setup project (that will only copy it to your installation path).
But after adding it to your setup project, you can copy your xml file to the location of your choice. Path of the xml file can be set using environment paths, for example Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
You can do it using a separate little console project that contains Installer class, where you copy your file and generally do additional things that need to be done during installation :
http://msdn.microsoft.com/en-us/library/system.configuration.install.installer.aspx
How to pass TARGETDIR into CustomActionsData?
http://www.codeproject.com/Articles/5821/All-about-Installers-Customizing-Windows-and-Web-s
http://msdn.microsoft.com/en-us/library/2w2fhwzz(VS.80).aspx
You can use TARGETDIR to get your installation path in yoour installerr class (just google it or use the link above, it's explained well there)
Then add your installer project's primary output to CustomActions in your SetupProject.
Related
I have a WPF project that is now finished, and I want to publish the app into an installer that other people can use.
When I publish the project, the project compiles into setup.exe, but on install the folders that I have do not get included.
I've been reading the guides, and made sure to include the files inside the folders as Content or a Resource. I've also made sure they are always copied. When some of my files are copied, they have a .deploy extension, and I need it to be an .xml in order for some function to read them. Images that I have in the app load fine however.
What do I need to do to have my custom files be EXACTlY as they are, xml as xml, txt as txt and so on. Also I have some empty folders, like this TempCF that I use at some point. Do i need to create it via code?
If you go to Project->Properties->Publish->Install Mode and Settings->Options->Deployment in Visual Studio, there is a "Use ".deploy" file extension" option that you can untick to get rid of the .deploy extension being added to your published files:
Empty project folders are not included in the output. Either put a dummy content file in them or create the folder dynamically as needed during runtime.
# Nikola L.
You could try to use the following methods to add the files in your program to the installation package so that you can have the files you need in your installation path. If I misunderstood your question, please let me know.
The steps are as follows:
1.Right-click on the Setup project and select View -> File System
2.In the File System page, right-click the Application Folder (File System on target Machine) and select Add->Folder(named User's Application Data ) -> Fileā¦-> find the file under your project and select the file you need.
Such as:
3.Right-click the Setup project.
Install your setup package.
You can find the files you added in your installation path.
The result is like the picture below:
I'm planning on my C# application having a folder called Data that is reused whenever the program is launched. I put it in the root of my Visual Studio solution which causes it to be where you see below
MyProject (File folder)
bin (File folder)
Debug (File folder)
MyProject (Application)
.
.
Data
obj
.
.
.
.
after the project is built ... but I'm guessing I'd want it where the actual application is, right? Or is it proper for me to instead have a "Create if doesn't exists" for that folder in my application? Sorry if this is considered a subjective question.
1) you may check it at the start of the program if it doesn't exist then you may create it.
Right click on your SOlution in visual studio>> Add new project>> Under other project types>> Choose>> Setup and deployment >> Visual Studio installer >> Set up project.
Setup projects are important in many cases, when you need to make any changes for first time installment or need to modify registry, need to copy some data folder or other settings for the first time.
2) Create a setup project and in your setup project you may create that data folder, which will be created when user will install the application.
I would prefer to use both option to avoid any issue in future.
From what it looks like in your example the data folder you created in your application/solution explorer. So far so good but it wont ever be created inside your project.
You have 2 options if you want it to be in the same directory as your application.
You create a .txt file or whatever you want to put into it later on in the solution explorer and say "copy always" in the properties
Is you create your folder manually inside your program. The base location of your program is usually AppDomain.CurrentDomain.BaseDirectory. Thus you could use Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + folderName).
For 2 this could be done on each run on the program (if the directory does not exist yet OR on setup of the program if you have a special setup routine).
As far as I'm aware all of these variants are legit and are dependent on your exact use case and personal taste.
I'm guessing I'd want it where the actual application is, right?
NO! Let's say you eventually bundle this program into an installer the puts it in it's own Program Files folder. Standard Users do not have write access to anything under the Program Files folder!. You just forced your program to require Administrator rights every time it runs.
Instead, you need to put your data folder in the Application Data special folder:
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
I'm planning to build my winform into a .exe file. I'm just wondering what to do with the XML files that my application needs?
I did some research and found out that I can add the XML files in the Resource folder before creating a .exe file.
Or I need to create a setup file? When the user runs the setup file, the XML files will be installed into their pc.Now I wonder which one is the best way to go for,
Note: XML files might get modified by the user.
If you want to ship the XML files as seperate to the .EXE then you can set the Copy to Output Directory to Copy if newer. (click on file and then go to properties).
OR if you want it as part of the .EXE I think you can change the Build Action to Embedded Resource.
I personally would create a Setup as per your edit and include the XML files. I usually just add everthing from the bin/release folder that is needed when I create a setup file.
You could either deploy the necessary files along with the executable in the same folder or embed them as resources (if they are read-only). If you need to modify them do not embed them as resources into the executable.
The correct way depends on how you intend to use the files. If the files always are deployed together with your application, the application never writes to them and they are never upgraded without upgrading the application, you can go with them embedded as resources.
If you need to update them separately from the application, you need to have them as physical files.
You don't necessarely need a installation package, unless you need to apply some logic during setup, such as updating the content of the setup based on user input or to check preconditions. The application can just be copied into place regardless of if you have embedded the files or not.
I have a WPF project and a post build event which copy files from a folder outside of the solution into the output directory.
I want to publish my application with Clickonce publish. The only problem is that the copied files are not included in the publish or the manifest.
I tried using MageUI.exe , msbuild /target:publish from the visual studio cmd and even tried to change the project file by hand including a beforepublishevent but none of that worked.
I am open to suggestions, but what I want is to take the output folder and make the installer install the output files. (e.g. install the .net 4 framework and visual c++ runtime libs)
If you don't want them in the solution, but you do want them in ClickOnce then the only possibility is to use an external tool to create the ClickOnce manifests as you can't add non-project files to the ClickOnce output in Visual Studio.
There are two options I know of:
Use MageUI to manage your ClickOnce manifests. You can add additional files to your application in Mage.
You could use some software that I created and sell called ClickOnceMore (www.clickoncemore.net). ClickOnceMore will allow you to add all the files in one directory to your ClickOnce manifests by adding a single folder include. You can also then control which sub folder on the client they get deployed to. It was designed to make scenarios like this simple. You can download a free trial on the web site.
I hope it helps. Apologies for the marketing plug, but I do think ClickOnceMore can solve your problem perfectly.
Instead of copying the files through a post-build event, why don't you include them inside the project, and mark Copy to Output Directory = Copy if Newer?
If they are DLLs, you can add them as reference instead.
There are other options to create installers such as WiX+SharpSetup. It's much more flexible, but also more complicated, and takes more time to create simple installers.
I want to copy a file that's in the same directory as the installer file to the application directory. I can't include the file in the installer.
the scenario:
I create an installer for my client.
the client will distribute the installer to an unknown number of third parties,
these third parties will need to change an aspect of the configuration for the application.
they will subsequently distribute the installer with their edited config to an unknown number of end users.
The end users need to be able to just double click the installer, no knowledge on their part can be assumed.
I can't/don't want to create a separate installer for every third party that will distribute the application.
The solution I've come up with is letting these third parties add a config file to be distributed together with the installer. This file will be copied to the application dir on installation. I created a custom installer class for this purpose.
The part where I am stuck is how to find the file. All the provided methods to find the active assembly etc inside the installer class seem to point to a directory inside Window\system32, instead of the original directory where the installer was launched from.
Any help greatly appreciated.
Is this what you are after? You pass custom data to the custom action, using one of the built-in, but hard to find parameters available when you design setup projects in Visual Studio.
http://adamhouldsworth.blogspot.com/2010/01/get-msi-location-during-setup.html