I have Visual Studio 2015 with Wix Extension 0.9.21.62588 and v4 toolset. According to the document these are the project references and variables I can use. In the pre build and post build steps I can access these fine
However I cant seem to access the other available options that a C++ project has access to example $(WindowsSdkDir), $(UniversalCRT_LibraryPath_x86) etc. Is it possible, if not is there a workaround
Usually you can do this by updating the $(DefineConstants) property in the project manually or through visual studio project properties > Build > Define preprocessor variables
You just need to use a semi-colon separated list of variable names-value pairs.
WindowsSdkDir=$(WindowsSdkDir);UniversalCRT_LibraryPath_x86=$(UniversalCRT_LibraryPath_x86)
In this format the $(VarName) references are the MSBuild properties. The name you want to use for your wix variables $(var.Name) can be anything you like.
Then in your wxs wix code you can access these values using $(var.WindowsSdkDir) or $(var.UniversalCRT_LibraryPath_x86)
Related
How does Visual Studio (2015) work with external tools like NPM and Typescript compiler (tsc.exe) etc.? I guess, at the time of building the solution or project, something must be telling MSBuild to run these extra tools. I want to understand this under the hood operation.
It all depends...
Visual studio has multiple services and features that interlink here:
Language Services - Visual Studio can be extended with so called language services, these provide intellisense, syntax analysis, highlighting etc. For Javascript and Typescript Microsoft provides a Language service that provides such information.
MsBuild - Underneath most of Visual Studio projects lives an MsBuild project. If you search your Program files directory you'll find an MsBuild folder and underneath that there are a number of target files. This includes one for Typescript which will transform your .ts files during build. These targets files either directly use the exec MsBuild task to run tools or provide a custom MsBuild task in the form of a .NET Assembly that implements specific interfaces. These tasks can either implement the required action themselves or shell out to a tool to have it perform the action.
Roslyn - For C# and VB.NET the parsing of the projects and the background compilation of the sources is handled by a new compiler called Roslyn. This actually runs in the background while you type and has a very powerful in-memory model of all your code in your project. Roslyn supports add-ins as well in the form of analyzers and refactor action that either provide the user with feedback on common errors or provide ways to automatically rewrite/change the code.
Task Runner - The Visual Studio Task Runner is a plugin for Visual Studio that first shipped as an extension and is now part of Visual Studio. It reacts to events in the IDE (build, test, etc) and can associate actions in your package.json or grunt or bower etc scripts. The plugin will make sure your script commands are executed at the right point in time during the builds.
Test Runners - The Visual Studio Test Window has support for extensions as well, so the Mocha and the Chutzpah extension in your project will be picked up and during the test execution these plugins will be asked to first list and later execute the tests. These runners act as a kind of proxy, feeding back the list of tests and their status after execution.
Custom extensions - There are many other ways in which some vendors extend Visual Studio by providing a generic extension. These extensions may contain any of the above elements or may just listen to the events generated by Visual Studio while you do your work and react on them.
You can see the references to the typescript items if you open the .csproj
with a text editor (or from visual studio : unload the project, right-click on the project and choose edit myproject.csproj )
You'll see the typescript resources :
<ItemGroup>
<TypeScriptCompile Include="src\config.ts" />
the target for the build :
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />
The external tools, are configured in Tools/Options :
I’m having some difficulty with the Visual Studio 2010 build process. To put it simply, I would like to pass the preprocessor definitions set up for the currently building configuration into a batch file via the Pre-Build Event command line.
The preprocessor definitions are in the projects properties under C/C++ > Preprocessor > Preprocessor Definitions. I do see the name of the macro as %(PreprocessorDefinitions) when in that property sheet, however that macro doesn’t show up in the Macro list for Build Events > Pre-Build Event.
Is there any way to access %(PreprocessorDefinitions) from within the Build Events > Pre-Build Event > Command Line?
Thanks!
Additional Details:
Let me be more specific… I’m using a slightly modified version of vs-android in order to build Android apps from within Visual Studio. I have in the past edited the vs-android source to add specific elements we need to the build process. I’ve noticed that the PreprocessorDefinitions are in an ItemDefinitionGroup called “ClCompile”. I can’t seem to access the defines using %(ClCompile.PreprocessorDefinitions) from within the .props or .xml build files.
Is there a way to tell Visual Studio to make %(ClCompile.PreprocessorDefinitions) part of the environment, so perhaps it will show up as $( PreprocessorDefinitions)? If so, I have not been able to find out how.
I have a project that was built for company X. Then they decided to allow company Y to use the product - and they wanted to make some minor branding-type changes. I come from a C programming background, so I added another build configuration that specifies a conditional compilation symbol depending on which brand the solution is being built for. Then the source code has a few:
#if COMPANY_X
// do stuff
#elif COMPANY_Y
// do different stuff
#endif
Now here's my question: Can I use the solution's build configuration to manipulate a single (Visual Studio Installer) setup project? Or do I have to maintain multiple setup projects to manage the differences between them (app name, install folder, manufacturer, etc.)? (Or perhaps more fundamentally, am I going about this all wrong?)
Background info: Visual Studio 2010, Visual Studio Installer, C#
You can use single vs 2010 solution and create multiple solution configurations (ideally for different company or different environments).
VS 2010 Menu --> Build--> Configuration Manager--> Select new from Active solution configuration. Using this approach you dont have to write conditional builds.
I've got a solution with many projects and WIX setup project. I'm using WIX 3.5.
One project (that is referenced from WIX setup project) contains a reference (an ordinary reference in VS) to:
C:\Program Files\WPF Toolkit\v3.5.50211.1\WPFToolkit.dll
(simply: setup project --- reference --> another project in solution --- reference --> WPFToolkit.dll; note that the "references" are not the same - the first one is some kind of WIX specific reference and the other is ordinary reference in Visual Studio)
I thought that maybe the line (automatically generated) in setup project:
<ComponentGroupRef Id="Product.Generated" />
may solve it for me (i.e. includes also WPFToolkit.dll in installer) but it doesn't.
Obviously, I can add the file manually in my wxs file but it will be harder for maintenance.
Is there a better solution?
Thanks!
If you want your install project to be more extensible when adding new WiX Files to a Component, I would suggest to create an external tool (could be a c# console app) to handle the WiX Files generation and add them to your install project. This tool can have a config file where you can setup which WiX Files correspond to each Component.
This tool can be added to an Automated Build process.
What you are seeing is an initial attempt to do exactly what you want via the WiX toolset. On the Property Grid for References to other projects in your .wixproj, you should have the ability to control "Harvesting" and what project output groups are harvested. Unfortunately, there are still some bugs in the feature so it doesn't always work.
If you want to get your hands dirty you can look at the Heat project harvester and how it gets wired into the .wixproj.
I've updated my default templates in Visual Studio for classes, interfaces, code files, etc. I removed the default namespaces and added a copyright header blurb.
Is there a way to use a variable or something in the template so I don't have to zip/unzip and re-run the vs installer to change the copyright header? (I'm a consultant, the code-owner isn't always me or my company).
Yes, you can. The documentation for this sort of thing is part of the Visual Studio SDK. There are already many variables you can use.
If you find you want to get fancy, look into the Guidance Automation Toolkit. A template using GAT can accept user input as well as information from the project and environment, can unfold one or more templates, filling in placeholders with the data gathered, and then can execute various actions against the unfolded templates, the project, or whatever.
You can get the complete example implemented here: Multi-Project Templates with Wizard: Visual Studio 2010 Sample