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.
Related
I added a filter and some .c files to my .vcxproj through the GUI but they won't build correctly because I'm in the process of adding all the correct environment variables.
Is it possible to temporarily exclude from the build a filter and its children?
As the name says, 'filter' is just view filter and has no effect on build system, thus, there is no easy way. You can only modify project and source files properties ('Excluded from build' of cpp in your case).
But... there is a workaround, which makes you edit all cpp files only once and works for all build configurations.
Create props file (View->Other Windows -> Property manager, right mouse button on your project and 'Add new...') and in User Macros add TempExclude with value 'Yes'
Now select all problematic files and in Excluded from Build type $(TempExclude) (Don't forget to select All Configurations and All Platforms)
Now you can edit just value of TempExclude in property file to get you files in/out build. If you dont define TempExclude it will include files into build.
I have a console application that I've been developing and I'm just about ready to publish it for consumption.
However, there's a file that the app needs to reference (a couple files actually) and I'd like to try to include these either during install logic or via an outside process. Here's the situation:
The application fires off a load test based on some criteria the user chooses. The load test is defined by a .loadtest file which is created outside of this project.
So what I would like for the installer to do is contain the .loadtest files and just shove them in a default directory that the project can reference.
I can't figure out how to add this specific file as a pre-requisite or anything though, in the publish wizard. Any ideas?
When you add a file to the solution, it does not automatically get attached as part of the build in some cases. If you right click the file in your solution explorer and select "Properties", change the build action to "Content". This will ensure that VS includes the file as part of the build/publish and places it in the output directory of the build process.
Usually, visual studio puts output files to bin/debug or bin/release.
When solution contains a large number of projects its not easy to modify each project output manually.
Also edits in csproj files no desirable, because some of them is shared between solutions..
My questions: Is anybody knows a tool, which can quickly configure output path ?
UPDATE: my problem solved by TFS Build
Presumably you have at least one project in each solution that is unique to that solution. In the Post-Build event of that, copy the contents of each project's output to the required location.
We often to this using a batch file. It's crude but effective. In our project that's unique to the solution we create a Release.bat file. This contains a number of file copies to copy all of the required components from the various output directories of the other projects. You can then just run the batch file in the post build event. We usually copy everything to a "Latest Release" fodler when the solution is built. If this becomes a proper release we will rename the Latest Release folder to the actual release number.
If you have multiple build configurations, or even just use the Debug and Release configurations, you can use an If statement in the Post-Build event to decide which batch file to run. So you could create a Debug.bat, Release.bat etc which do what you need. It can be tedious to set them up and get them working correctly at first, but they are very useful once fully implemented.
Customize your project using the msbuild properties which you can do if you follow these steps:
Go to the solution explorer and unload one project by right clicking on it and select Unload Project.
Then right click again on the unloaded project and select Edit Project. This will open the XML definition of your project, and you will have intellisense for the layout which will help you perform the next steps.
In the visual studio editor find the first PropertyGroup tag and add these lines near or at the end of the closing PropertyGroup tag:
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<BuildDirectory Condition="$(BuildDirectory) =='' or $(BuildDirectory) == '*Undefined*'">$(SolutionDir)\build\</BuildDirectory>
The above SolutionDir is defined in msbuild properties which you can obtain using this answer: msbuild script using solution information and also check out the well known msbuild properties here
The next step is to find the OutputPath tag for each configuration and edit it like this:
<OutputPath>$(BuildDirectory)\x86\AutomatedDebug\</OutputPath>
The example above assumes you have a configuration named AutomatedDebug with destination platform x86.
The output will be
x:\projects\whereever-your-solution-is\build\x86\AutomatedDebug\
Repeat for each project.
To unload more than one project, collapse all projects in the solution explorer and shift click or ctrl click to select all or some projects, then right click on the selected group to unload, unfortunately you cannot do this for editing, at least in visual studio 2010.
I am the first to admit that this is somewhat cumbersome to do for existing projects, but you could easily create a visual studio project template that has these settings changed so that new projects will use a more convenient default output directory.
You cannot edit the output directory directly in visual studio because the project properties editor escapes any $() enclosed text.
Also you could only modify the OutputPath using the name of a system environment variable enclosed in $(). This last option is to enable a global output directory.
If you build any single project modified in this way using msbuild directly in the commandline the output directory will be created one directory above from where you ran msbuild
..\build\x86\AutomatedDebug
If you are in a team, you should warn them not to edit the output directory directly by hand, as this action will overwrite any customization.
Hope this info is useful.
Greetings.
When adding a new item in a Visual C++ project, the default path for the new file is the project path. Are there any per-project or per-solution settings that allow this default path to be modified?
For example, to add new files by default to a subdirectory of the project folder, or even to somewhere outside the project folder?
I understand that filters can be used to automatically organize files visually within the Solution Explorer based on file extension, but I would like to actually place the physical file in another location without the need to browse to it.
I'm using a Visual C++ project as a container to to manage and organize (filter) editing of runtime-compiled files, and don't want developers to accidentally place new files outside of the intended folder, nor do I want the project file to exist in this code folder.
I did discover that if you create a new file in a sub directory of the project, that the Add Item dialog will default to that path when you add another file during that session, but it does not persist the default to the project or solution for future sessions.
I don't believe there's anything built-in. Some commercial add ins make the behavior better. For example, Whole Tomato's Visual Assist X package always uses the same directory as the currently open file, IIRC.
There are a couple of open source add ins that let you modify the behavior. For example, this one.
I've added several directories, libraries such as matlab, opencv, etc to compile my current C file in Visual Studio project.
All my upcoming projects will require the same setup/properties. Do I need to setup my each project's properties individually or I can do something to apply it to all ?
Try using Property Sheets. These can create a single properties file that can be inherited by multiple projects.
Use "View > Other Windows > Property Manager" to bring up the Property Manager. It will show your projects and configurations.
Right click a configuration, and select "Add New Project Property Sheet...". You can name it, and select a location that works for all your projects.
Once created, you can edit its properties just as you would a build configuration.
To use that property sheet as the basis for other projects, just right click the configuration or project, and select "Add Existing Property Sheet...". Browse to where you saved the original sheet, and it will be inherited.
Any changes to the original sheet will be applied to any project that inherits it, unless they are overridden. If you go into properties higher up the chain, properties that override will have bold type for their values. To get them to always use the value in the base sheet, there will be a "inherit from parent or project defaults" option where applicable.
I am using AtmelStudio 6.1, which is built on Visual Studio 2010 (I believe), and yet doesn't have any Property Manager that I can find.
So, the hackish system I use is:
close (or at least unload via the contextual menu) the project whose configuration you want to modify
open its .cproj file (which is XML) in any text editor (VS works nicely),
MAKE A BACKUP COPY OF IT SOMEWHERE ELSE JUST IN CASE,
open the .cproj file of the project whose configuration data you want to copy,
look for the configuration data you want. Configurations are inside of PropertyGroup tags; for example, in my case it looks like
<PropertyGroup Condition=" '$(Configuration)' == 'Preprocess only' ">
for the configuration named "Preprocess only". Copy from the beginning of that tag until the end of the corresponding
</PropertyGroup>
tag.
Paste the block into the destination .cproj, just after other
</PropertyGroup>
tag. Make sure that the name of the configuration is unique in this file. Save.
You're finished. Now open the project normally in VS and you'll be able to select the added configuration.
For Visual Studio 2010+ you can make a Project Template.
If you choose to automatically add the template to Visual Studio in the template creation wizard, when you create/add a new project, the template will appear (after restarting Visual Studio). Projects created with this template will have the same project properties!
To add source code files to the template, the easiest way is to rearrange the source code files in solution-explorer to be in the root (not under any folder). After doing that, THEN generate the template.
Why? Sometimes putting your files under the default Source Code solution-explorer folder (not in file explorer, the .project.filters label) will fail to copy the source file to the template, you'll see "the document cannot be opened. it has been renamed deleted or moved" when you try to use the template and the file you wanted in the template will NOT be in the file explorer.
If you do want solution-explorer folders, you will have to add them manually to the template by unzipping the template folder, making changes, then re-zipping it again.
For example, literally copy and paste the source files you want the template to have in the template folder and edit the .vstemplate file. M$ Doc on template editing.
<TemplateContent>
<!-- put new file references here and/or in your .vcxproj .vcxproj.filters -->
TargetFileName="HelloWorld.cl">HelloWorld.cl</ProjectItem>
<ProjectItem ReplaceParameters="false"
</TemplateContent>
Related questions:
How do I use VS template I created?
How can i load a template I have created in Visual Studio?
How copy visual studio project?
Simply copying and pasting entire projects and solutions is not recommended for complex or shared projects since various GUID s and filenames may overlap - causing bugs.
For MSVS 2017, the process #AaronMK mentioned doesn't work. Instead do the following:
View -> Other Windows -> Property Manager
Add New Property Sheet.
Edit whatever options you want there.
Give it an appropriate name so that you remember it.
Right button on it and hit "Save {myPropertySheet}"
It would be wise to place it alongside the default property sheets and that you can add it whenever you want (by Property Manager -> Add Existing Property Sheet -> Browse to its location). This directory is: C:\Users\{myUsername}\AppData\Local\Microsoft\MSBuild\v4.0
Alternatively you can edit the default property sheets and use these by default. I wouldn't advice it though as they provide a fallback option in case you mess up. So make backups first if editing default files.