How to add xml file during installation using wix - wix

I want to create the following xml during the installation created by wix 3.9.
<?xml version="1.0" encoding="utf-8"?>
<MappedUsers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<UsersList>
<LyncUserID>
<CustomUserName>John.Smith</UcaUserName>
</LyncUcaUserID>
</UsersList>
</MappedUsers>
Tried creating the file using following code but got the error message during installtion that file doesn't exists.
<?define UserNameFile="[AppDataFolder]ThirdParty\LyncUcaUserMapping.XML" ?>
<util:XmlFile Id="UserMapping" Value="[USER_NAME]" ElementPath="/UsersList/LyncUserID/add[\[]#key='UcaUserName'[\]]" Action="setValue" File="$(var.UserNameFile)" Name="value" Sequence="7" />
Since I could not create the file during the installation I created the file manually and placed in my appdata folder. But then above code didn't work either as it says "failed to find the following node".
What am I missing?

Best method to do this is first you copy a sample xml file as below.
<?xml version="1.0" encoding="utf-8"?>
<MappedUsers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
</MappedUsers>
Then edit it using a custom action.
Here is a link which shows how to edit xml files using c#
http://support.microsoft.com/kb/301233
Following link shows how to add custom actions to a wix project.
http://wixtoolset.org/documentation/manual/v3/wixdev/extensions/authoring_custom_actions.html

Related

Insert a source file in programlisting with xinclude in docbook

I've the following file tree
mainfolder
|-assembly.xml
|
|-chapters
| |-introduction.xml
|
|-source
|-example01
|-main.cpp
assembly.xml is the assembly file of my docbook. It contains a reference to introduction.xml.
This is the assembly:
<?xml version="1.0" encoding="UTF-8"?>
<assembly version="5.1"
xmlns="http://docbook.org/ns/docbook">
<resources xml:base="chapters/">
<resource href="introduction.xml" xml:id="introduction" />
</resources>
<structure xml:id="main-book">
<info>
<description>Book chapters</description>
</info>
<output renderas="book"/>
<module resourceref="introduction"/>
</structure>
</assembly>
introduction.xml is docbook chapter. I want to insert in it an example including the main.cpp.
<?xml version="1.0" encoding="UTF-8"?>
<chapter version="5.1"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xila="http://www.w3.org/2001/XInclude/local-attributes"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:trans="http://docbook.org/ns/transclusion"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<info>
<title>Introduction</title>
</info>
<section>
<info>
<title>Chapter title</title>
</info>
<para>
You can see an example:
</para>
<example>
<title>main example</title>
<programlisting language="c++">
<xi:include href="./../source/example01/maiin.cpp" parse="text" />
</programlisting>
</example>
</section>
</chapter>
Anyway, when I build the book (I'm using personal edition of XMLMind), I don't see anything. In the PDF the example is printed, but instead of the source code inside the main.cpp I see
<xi:include></xi:include>
What I'm doing wrong? How can I include the source code from the file?
I've reproduced your situation in a different ways and got things working in a both cases.
You didn't mention the exact steps you make to build a book using XMLMind XML Editor (XXE for short), but the following steps certainly worked well.
None 1: I've used XXE Professional Edition, but as I know the difference between versions is only in putting random character within text if generating PDF from Personal Edition.
Note 2: XXE says that <description>Book chapters</description> element is not allowed within you context. Despite that fact, the assembly can be generated successfully.
1. Getting things working within XXE
Open an assembly file in XXE.
Select Convert > Convert document > Convert to PDF.
Select a path to save pdf file and press OK button.
2. Getting things working manually in command line
Use your exact files and DIR structure (I included my own .c file sample for my own test).
Use XXE assembly processor: http://www.xmlmind.com/xmleditor/assembly.shtml - it has the same codebase that XXE used for working with assemblies from XXE GUI.
Get docbook book file from assembly:assembly-1_0_2_01/bin/assembly -v assembly.xml docbook_book.xml In my test I've got the .c sample file included - that proves that assembly utility works well with XInclude.
Get .pdf manually: fop -c <config_file> -xsl <path_to_docbook_ns_stylesheets>/fo/docbook.xsl -xml docbook_book.xml -pdf docbook_book.pdf
I've got the final result with .c sample included in both cases.

Visual Studio won't open vb solution

Whenever I try to open a VB solution on Visual Studio 2013 it won't open. Instead I can open the vb file but I can't run the program. Whenever I run it, it gives me this error message.
C:\Users\George\Documents\Visual Studio 2013\Projects\RealCalc\RealCalc\RealCalc.vbproj : error : The project file could not be loaded. Root element is missing. C:\Users\George\Documents\Visual Studio 2013\Projects\RealCalc\RealCalc\RealCalc.vbproj.user
Please help
Sounds like either your vbproj or vbproj.user file is corrupted. The first few lines of these files should look like this (note the root XML node):
vbproj:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<PropertyGroup>
...
vbproj.user:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<PropertyGroup>
...
I'd suggest trying to fix it by hand using a good text editor. You can also try deleting the vbproj.user file altogether and letting VS regenerate it.

Octopus Deploy cannot find namespace in transform file

Have been trying to apply a transformation to one of my config files in Visual Studio 2010
The target file starts like this:
forms.config
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:x="http://www.sitecore.net/xmlconfig/">
<sitecore>
<formsDataProvider type="Sitecore.Forms.Data.DataProviders.WFMDataProvider,Sitecore.Forms.Core">
<param desc="connection string">connection string goes here</param>
</formsDataProvider>
...
The transformation file is as follows:
forms.Staging.config
<?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations
see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:x="http://www.sitecore.net/xmlconfig/" xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<sitecore>
<formsDataProvider type="Sitecore.Forms.Data.DataProviders.WFMDataProvider,Sitecore.Forms.Core">
<param desc="connection string" xdt:Transform="Replace" xdt:Locator="Match(desc)">connection string for staging goes here</param>
</formsDataProvider>
</sitecore>
</configuration>
When the staging build runs on Octopus this is what's in the log:
DEBUG [XML Transformation] The expected namespace http://schemas.microsoft.com/XML-Document-Transform was not found in the transform file.
Have tried to remove the other xmlns attributes to no avail.
Said namespace is clearly on the transform file as an attribute in the configuration node. We have numerous other such files and transformations are applied fine. The Build Action for all transform files is set to Content.
Not sure if we can make Octopus log such messages as errors instead of Debug though.
Has anyone else had a similar problem?
Thanks in advance.
It looks like it might be trying to apply your forms.config as a transformation file instead of a target.
What do you have specified in the deployment step's Additional Transforms? Did you accidentally include forms.config itself?

Getting Project Version Information During MSbuild build

I'm attempting to automate the building of our installers through MSBuild. The problem that I have come up against is getting the Version information of the C# project which is calling the custom MSBuild script, which would then pass the version number into Wix during the build process.
What I would like to do is to set the version into some properties like this:
<ProductVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion).$(BuildVersion)</ProductVersion>
<InstallerName>"$(ProductName)-$(ProductVersion).msi"</InstallerName>
The version is updated as part of our continuous integration build and incorporating the version number into each installer that is built on our continuous integration server helps us in producing an application that is Continuously Deployable.
Any help would be greatly appreciated.
The way I have solved this problem is by creating a 'version.xml' file in my code repository. This file contains the following data
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5"
DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VersionMajor>0</VersionMajor>
<VersionMinor>1</VersionMinor>
<VersionBuild>1</VersionBuild>
<VersionRevision>0</VersionRevision>
</PropertyGroup>
</Project>
In my case this file is checked in but it should not be too hard to generate this file with information from the build server or whatever is desired.
During the build a custom MsBuild taks (similar to the TemplateFile task) creates an assembly info file and a Wix include file from their respective template files. The 'version.xml' file is accessed by including it in the MsBuild script. For example like this:
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion="4.0"
DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Include the version info file so that we can pull the version info from it -->
<Import
Project="$(DirWorkspace)\version.xml"
Condition="Exists('$(DirWorkspace)\version.xml')" />
<!-- Generate a file with the version information -->
<Target Name="GenerateAssemblyInfoVersionNumber">
<ItemGroup>
<VersionTokens Include="Major">
<ReplacementValue>$(VersionMajor)</ReplacementValue>
</VersionTokens>
<VersionTokens Include="Minor">
<ReplacementValue>$(VersionMinor)</ReplacementValue>
</VersionTokens>
<VersionTokens Include="Build">
<ReplacementValue>$(VersionBuild)</ReplacementValue>
</VersionTokens>
<VersionTokens Include="Revision">
<ReplacementValue>$(VersionRevision)</ReplacementValue>
</VersionTokens>
</ItemGroup>
<TemplateFile
Template="$(FileTemplateAssemblyVersion)"
OutputFileName="$(FileGeneratedAssemblyVersion)"
Tokens="#(VersionTokens)" />
</Target>
</Project>
The AssemblyInfo.VersionNumber.cs file which is included in the C# projects is generated from a template file that looks like:
//-----------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost
// if the code is regenerated.
// </auto-generated>
//-----------------------------------------------------------------------
using System.Reflection;
[assembly: AssemblyVersion("${Major}.${Minor}.${Build}.${Revision}")]
[assembly: AssemblyFileVersion("${Major}.${Minor}.${Build}.${Revision}")]
// The AssemblyInformationalVersion stores the version that will be displayed in
// Windows explorer.
[assembly: AssemblyInformationalVersion("${Major}.${Minor}.${Build}.${Revision}")]
During the replacement process the ${TEXT_HERE} sections are replaced with their respective values.
The Wix include template file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Include xmlns="http://schemas.microsoft.com/wix/2006/wi">
<!--
This is a generated file.
Do NOT make changes to this file.
They will be undone next time the file is generated.
-->
<!-- The current version -->
<?define CurrentVersion = "${Major}.${Minor}.${Build}"?>
<!-- The install version string -->
<?define ProductVersionFolder = "${Major}.${Minor}"?>
</Include>
After including this file it is possible to refer to the CurrentVersion and the ProductVersionFolder variables in the Wix installer where ever it is needed.
By using this method the version information is stored in a single location and can be accessed by all parts of the build.

Wix Include file (.wxi) throws exception

I am a beginner in Wix and we are trying to migrate from Installshield to Wix. However I am stuck with an error which I am unable to resolve. I have done my share of research online before posting this message and I am hoping to get some help from you experts in case someone had a similar problem and would be kind enough to point out the silly mistake I am making here.
Here is my Wix include file: properties.wxi
<Include>
<?define Language="1033"?>
<?define Manufacturer="ABC Inc"?>
<?define Name="TRIAL-MSI"?>
<?define UpgradeCode="....GUID...."?>
<?define Version="09.00.0021"?>
<?define Comments="Contact: team#abc.com"?>
<?define Description="TRIAL Application"?>
</Include>
And I am calling it in my code as follows:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?include properties.wxi ?>
<Product Id="*"
Name="${var.Name}"
Language="${var.Language}"
Manufacturer="${var.Manufacturer}"
UpgradeCode="${var.UpgradeCode}"
Version="${var.Version}" >
<Package Comments="${var.Contact}"
Description="${var.Description}"
InstallerVersion="200"
Keywords="Installer,MSI,Database"
Languages="${var.Language}"
Manufacturer="${var.Manufacturer}"
Compressed="yes"
Platform="x86" />
I am compiling my script on the command line:
candle -arch x86 -I properties.wxi trial.wxs
I keep getting errors as follows:
error CNDL0048 : The document element name 'Include' is invalid. A Windows Installer XML source file must use 'Wix' as the document element name.Source trace:
And I guess because Candle did not accept the include file, it throws exception for:
error CNDL0008 : The Product/#Language attribute's value, '${var.Language}', is not a legal integer value.
Could someone please help me with this? Any help is greatly appreciated.
I had this error when migrating wxs files to wxi
Setting the files Build Action property in Visual studio from Compile to Content fixed it.
The -I flag to candle is used to specify a directory to search for include files:
usage: candle.exe [-?] [-nologo] [-out outputFile] sourceFile
[sourceFile ...] [#responseFile]
-I add to include search path
The Wix preprocessor will automatically look in the directory of the current source file for include files so there is no reason to specify the include file on the command line. Your command line should only include the Wix source files:
candle -arch x86 trial.wxs
UPDATE:
Wix variables are inserted using $(var.VARIABLENAME). You have all of your variables surrounded with curly braces instead of parentheses.