How to create windows MSI in separate solution? - visual-studio

How to Create a MSI for windows Applications which is available in different visual studio solution.

If you have installed the installer extension (if not, see notes below), open Visual Studio, then do the following (at this point, no solution is opened):
If you start with a new solution, select File -> New Project.(In case you want to add the installer project to an existing solution instead, right click on
the solution in the solution explorer and choose from the context menu Add -> New
Project.)
In the New Project dialog, select "Other Project Types", then "Visual Studio Installer" and there "Setup Wizard" (Alternatively you can also select a Windows setup project or a Web setup project directly - the wizard has the advantage that it will ask you about several items)
In the Setup Wizard, you can choose whether you want to create a setup for a Windows application or for a Web application. Here, select Windows application.
Click Next >. The "Choose files to include" dialog appears. This step is important, because here you specify which files you want to add to your installer package. Check the items you need to include - for localized projects I suggest that you add: "Locally copied items, Runtime Implementation, Localized resources, Content files" and "Primary output."
Click Next > again to bring up the last page ("Create project" dialog), then click Finish
You have now a solution with one setup project. Now you can add an existing project (select the solution, right-click and select "Add existing project"). After you have done that, right-click on the setup project and select "Add -> Project Output". Now you can select the items to be included in your setup project.
If required, you can also add other assemblies via "Add -> Assembly..." or, if you have that, you can add merge modules.
Notes
You need to install the extension "Microsoft Visual Studio 2017 Installer Projects" (via Tools -> Extensions and Updates, search it online in the Visual Studio Marketplace) to be able to select the installer as described above
that the project you have added can be part of a different solution.
The 4 most important properties of a setup package are: Version, ProductCode, Upgrade code and Platform (default is x86). Version is just a number (e.g. 1.0.1) while the other two properties are GUIDs. If you change the version in the package properties, then Visual Studio asks to create a new ProductCode (if you answer the question with "Yes" - which is recommended). This allows the Windows installer to distinguish the differrent packages from one another and allows to upgrade a package, because the UpgradeCode isn't changed.
Additionally, the default value for RemovePreviousVersions is false - but in most cases you want to change this to true (remember what I said before about ProductCode and UpgradeCode): To remove old versions automatically when you install a new version.

Related

Add existing files to visual studio project

I have a straightorward console application that I build using code::blocks. A client has requested a microsoft visual studio project to build it. So I downloaded and installed visual studio and created a project. Now I am trying to add my source files to the project.
Various online help pages say "Select project; select menu item "Add Existing Item" ( e.g. https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/9f4t9t92(v=vs.100). I cannot find "add existing item"! Add new item simply adds an empty file.
I tried dragging files from windows explorer onto the project, but this REMOVES the file from where it belongs - NOT what I want to happen.
Surely there must be a way to do this! Even without using alternative IDEs, different projects frequently must share common source code, so source files from one project need to be added to another.
The answer is to use File | New | Project from Existing code rather than simple 'New Project' when creating the project

Creating an installer for Visual Studio 2010 solutions (one or more projects)

I ran into some troubles when creating an installer for my Visual Studio 2010 solution (which has multiple projects) so I thought I'd make a quick guide to how I got it working...
Here is how I did it:
Create a new Visual Studio Installer project which is located under
Installed Templates/Other Project Types/Setup and Deployment/Visual Studio Installer.
Make sure you add it to you current solution, you can do this by right clicking on the solution name in the solution explorer and clicking Add>New Project
From there select Setup Wizard, give it a name and click OK
A wizard will open, click Next
then select Create a setup for a Windows application
then click Next again. Select all of the groups you want to include, namely: Content Files, Source Files, Primary Output
Then click Finish
In the solution explorer you will see a bunch of buttons find the one that's tool tip says File System Editor and click it. You will see three folders in the file system editor, the only one we really care about is the Application Folder. That folder is where your projects build output should be.
To add files to it if they are not already there right click > Add > File...
Note: You cannot add entire folders (which sucks) and the folder structure in the Application Folder should be identical to that in your projects build.
You should create each folder and then add the files to it.
If you have multiple projects you should set the build directory to the same folder under the release build settings. To do this, open your solution, and for each project, right click/Properties go to the Compile tab, set it's configuration to Releaseand its Build output path to some folder (same for each project) (If you have an XNA project make sure its Content Build/Configuration is also set to Release).
Now select Release from the drop down menu on the tool bar (it most likely says Debug now)
Right click on your solution on the solution explorer and click Build Solution
Now all of your solutions built files will appear in the folder you chose in the compile tab. All of these files are what needs to be added to the Setup Projects Application Folder (in the same structure)
Customise the installer: click on the project name in the solution explorer and look through it's properties, change what you want (i.e Author, Manufacturer, Title - these make a difference to the installers output directory and text)
Build the installer project (same way as mentioned above) and you are done.
Feel free to comment with questions

How do I change the target platform in a console app in Visual C# 2010 Express or Visual Web Developer 2010 Express?

I don't see any other value other than 'Any CPU' in the drop down list in Properties -> Build -> Configuration -> Platform in Visual C# 2010 Express or in Visual Web Developer 2010 Express.
I just removed some 64-bit dlls and got their 32-bit versions and added a reference to them.
Since then, I've been receiving a BadImageFormatException.
Is it the platform or the platform target?
If you want to add a new platform then do this:
Open the Configuration manager for your solution.
Expand the Platform combo for the project. It will show several items: Any CPU, and .
Press This will open a new dialog to add a new target for your solution. Select x64 for the new platform and Any CPU as the target from where to copy the settings. You can also check the "Create new solution platforms" if you want to add a solution target also.
Then, if you go to the project properties you can select this platform.
I found a couple of suggestions elsewhere but they haven't worked for me so far.
I found this one to be the most useful of all.
http://social.msdn.microsoft.com/Forums/en-US/d4fa83dc-eed1-4ead-96a1-78bbd9ba6d3a/vb-express-target-x86-platform?forum=vblanguage
For anyone who faces this same problem later, here's help. It says:
Express Editions:
The VB and C# Express products do not expose the
Target property inside the development environment.
You will need to carefully modify the project file
using a text or XML editor.
1. Close the project and/or solution
2. Select Open File from the File menu
3. Navigate to the project directory, and highlight
the project file
4. Press the Open button, the project file should open
in the XML editor
5. Locate the first <PropertyGroup> section and add
the following line:
<PlatformTarget>x86</PlatformTarget>
1. Save the project file
2. Reopen the project and/or solution using
Open Project/Solution from the File menu
3. Continue with development, debugging, and testing
Alternatively, if the application is targeted to 64-bit
platforms, you can ensure that the COM controls added to
the application have 64-bit equivalents on the development
and deployment computers.
JohnWein added the following:
Using the above method targets the x86 platform, but it
doesn't show the "Configuration:" and "Platform: " boxes
on the Properties tabs. To get this feature, I made a
template of one of the projects that shows these boxes.
Now I can target a platform and know what platform I
have targeted.

Windows Driver Development: Deploy option missing in Visual Studio 2012

I was trying to compile and deploy the WFP sample obtained from MSDN called msnmntr but the same problem applies to all samples.
This and all samples fail to deploy because there's one step in the documentation that are missing in Visual Studio 2012 Ultimate.
It says:
1) Open the property pages for your driver package. Right-click the driver package project in Solution Explorer and select Properties.
2) In the property pages for the driver package, click Configuration Properties, click Driver Install, and then click Deployment.
However there's no such option in the Visual Studio 2012 as you can see in the screen below:
I would like to know what I'm doing wrong.
This is the answer I received from Microsoft support.
Open msnmntr.sln in Visual Studio.
In Solution Explorer, right-click Solution msnmntr (2 projects), and choose Add > New Project. Navigate to Windows Driver > Package. Add a new Driver Install Package named msnmntr Package.
In Solution Explorer, right-click Solution msnmntr (2 projects), and choose Configuration Manager. Choose the configuration and platform that you want (Example: Win8 Debug, x64).
In Solution Explorer, right-click msnmntr Package, and choose Properties. Navigate to Configuration Properties > Driver Install > Deployment. Check Enable deployment. Check Remove previous driver versions before deployment. Enter the name of your target computer. Select Do Not Install.
In Solution Explorer, locate and open msnmntr.inf. In the [Version] section, add these lines:
Class = ActivityMonitor
CatalogFile = msnmntr.cat
Just above the [Strings] section, add these sections:
[SourceDisksNames]
1 = %DiskId1%,,,""
[SourceDisksFiles]
msnmntr.sys = 1,,
On the Build menu, choose Build Solution.
Locate the INF file on the target computer (Example: C:\DriverTest\DriverFiles\msnmntr.inf). Right-click the INF file, and choose Install.
On the target computer, open a Command Prompt window as Administrator, and enter net start msnmntr.
So I had the same problem regarding a sample I am working with. It all came from being confused about what project they actually wanted me to edit. it turns out it wasn't the driver project, but the one called "package". Not sure if you have such a package, but that was the problem in my case.

Visual Studio 2008 Setup Project is not generating Setup.exe anymore

I have a Visual Studio 2008 Setup Project that when compiled in the past would generate a Setup.exe in the output directory along with the .msi output file. Now it no longer generates the Setup.exe which I actually do need.
Did I change a project setting without realizing? How do I get it to generate it again?
Try opening project properties, click Prerequisites button there and check "Create setup program to install prerequisite components".
This is for Visual Studio 2005, not sure if it works for Visual Studio 2008.
1, Go to file menu > click Add > new project >now “Add New Project” Dialog appear.
2.Select “Other Project Types” and click “Setup and Deployment” projects,Choose “Setup Project”give name project name in name text box finally click OK.
3.New project appear in solution explorer,for example you give the name “MyEXE”..it will display with this name.
4.right click the MyEXE > go View > click “File System”
5.You can see the “File System on TargetMachine”under three folders
Application Folder
User’s Desktop
User’s Program Menu
6.Select Application Folder and right click Add>Project Output>select Primary output
select User’s Desktop richt click on the second window>click create new shortcut>select output file from Application folder>change the file name from primary output name to MyEXE
next >>
same procedure follows the user’s program menu also
8.If you want to change the Manufactures name for exe,just right click the project go to properties
change the properties as per you requirement
9.Finally Build the new project After successfully Build the project myEXE(Setup) will be appear in Application Debug or Release folder(depend upon the properties settings)
EXE available # this location
When you want to install the EXE on the client machine,you should be installed .NET Framework on that mc because,Applications and controls written for the .NET Framework version 2.0 require the .NET Framework Redistributable Package version 2.0 to be installed on the computer where the application or control runs.

Resources