If your C# program runs just fine when you’re inside Visual Studio but your build fails when using the Installer Project, this article may be the solution you’re looking for. My first attempt to build an Installer project generated the following errors:
ERROR: File ‘log4net.dll’ targeting ‘AMD64’ is not compatible with the project’s target platform ‘x86’
WARNING: File ‘log4net.dll’ targeting ‘x64’ is not compatible with the project’s target platform ‘x86’
Build process cancelled
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
Although my application target is set for an x64 platform, the Installer project is attempting to build for an x86 platform. After searching for hours, I found the simple solution on StackOverflow to address this concern.
Click on your Installer project. Click “View” on the main Visual Studio menu bar, then click “Properties Window” to show the “Deployment Project Properties.” Do not right click on the Installer project and click properties as the Property Pages window appears. The Deployment Project Properties pane should appear as pictured below:
To fix the errors generated by the build, change the TargetPlatform to x64 using the dropdown box.
The build was successful after changing the TargetPlatform to “x64.”
Creating a Windows Installer project for your C# application in Visual Studio:
Type “setup” in the search box next to the Help menu and click on either the “Setup Project” or the “Setup Wizard” (recommended).
Choose the Setup Wizard and simply follow the prompts as they appear.
Configure your new project.
Enter the Project name and Location as applicable for your project and click “Create.”
Read the information on the “Welcome to the Setup Project Wizard” and click “Next” to create your new setup project.
Choose a project type.
In this case we will choose “Create a setup for a Windows application.” Click Next after making your selection.
Choose project outputs to include.
When you click on a check box in the list of “outputs”, a Description appears below the list box stating what the output group is.
Make your selections and click Next.
Choose files to include.
Click “Add” to browse for files you want to add to your project like the Icon file we will use in our project. You can search the internet to find free Icon files or create your own if you have a tool or app to create icons. Click “Next.”
A brief Summary, list of Project groups to include, and Additional files appears:
When you click finish, a new Setup Project will appear in the Solution Explorer.
When building your project, a message appear as shown below.
Be sure to perform any additional actions to ensure a successful build of your new installer.
When the “Create” process is complete, a new Setup Project will appear in the Solution Explorer and a new tab pane will appear in the editor window.
In our case, the “Application Folder” contains all the files in our installer. The “User’s” Desktop and Programs Menu folders are empty. We can also see all the files under the Setup project in the Solution Explorer.
Building your new Installer
It is now possible to build your Installer. Right click on the Installer Project you just created and select Build. To see the results of your build, View the Output pane. If all went well, you should now have an Installer for your application.
Set Installer Properties
Click on your new Setup Project then, from the main Visual Studio menu bar, click View > Properties Window. This is not the same “Properties” option that appears when right click on Setup Project. A “Properties” pane should appear as shown below:
Set the Target Platform to target platform of the machine for which you intend to install the application. Our first build attempt failed as the TargetPlatform was set to “x86” as shown above. The build was successful after changing the TargetPlatform to “x64.”