Localize WiX installer which uses the Firewall extension - msbuild

I've got a WiX installer project which uses MSBuild to generate the MSI file. The WXS file includes the WiX firewall extension:
xmlns:fire="http://schemas.microsoft.com/wix/FirewallExtension"
I've defined two cultures in the MSBuild file with the following definition:
<PropertyGroup>
...
<Cultures>en-us;no-no</Cultures>
</PropertyGroup>
I've also added the translated resources:
<ItemGroup>
<EmbeddedResource Include="lang\Firewall_no-no.wxl" />
<EmbeddedResource Include="lang\WixUI_no-no.wxl" />
</ItemGroup>
These represents translation to Norwegian for the Firewall extension and the WixUI extension. When I run the build it succeeds with the en-us part, but the no-no part fails with the following error messages:
C:\delivery\Dev\wix30_public\src\ext\FirewallExtension\wixlib\FirewallExtension.wxs(19):
error LGHT0102: The localization variable !(loc.WixSchedFirewallExceptionsInstall)
is unknown. Please ensure the variable is defined.
....
Couple of issues: I don't know where the C:\delivery directory comes from. I don't have such a directory. The localization variables referenced in the error message have been translated in the Firewall_no-no.wxl file.
When I run MSBuild with more detailed information I see the following output right before the error message:
Task "Light"
Command:
C:\Program Files (x86)\Windows Installer XML v3\bin\Light.exe -cultures:no-no
-ext "C:\Program Files (x86)\Windows Installer XML v3\bin\WixUIExtension.dll"
-ext "C:\Program Files (x86)\Windows I nstaller XML v3\bin\WixUtilExtension.dll"
-ext "C:\Program Files (x86)\Windows Installer XML v3\bin\WixFirewallExtension.dll"
-loc lang\Firewall_no-no.wxl -loc lang\WixUI_no-no.wxl
-out F:\Projects\MyProd\MyProj\Installer\bin\Debug\no-no\MyInstaller.msi
-pdbout F:\Projects\MyProd\MyProj\Installer\bin\Debug\no-no\MyInstaller.wixpdb
obj\Debug\MyProj.wixobj
As the details show, the MSBuild task results in having two -loc parameters to the Light executable. Not sure if that would be the reason for this problem. Any ideas on how to solve this?

It seems that the reason for this error was very simple. I got the exception because I hadn't changed the Culture="no-no" attribute in the WixLocalization tag. Setting this value made the errors disappear.

Related

Skipping restore for project 'SetupWix.wixproj'. The project file may be invalid or missing targets required for restore (NU1503)

We are using Wixtoolset V3.9 to build our setup. We use the following command to start a build:
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" /restore /t:Rebuild /p:Configuration=Release /p:Platform=x64 MySolution.sln /p:BabelEnabled=true
We need the parameter /restore to restore the nuget-packagages on our build-server. Since we build our Wix-Setup by MSBUILD 16 we get the following warning:
Skipping restore for project 'SetupWix.wixproj'. The project file may be invalid or missing targets required for restore.
The warning belongs to category NU1503 (whatever this means). We cannot find a way to solve or even suppress this warning. We have tried to suppress it by adding the code NU1503 to the Project-Properties:
Whatever the reason, the warning still appears.
Question: How can we solve or suppress this warning?
TL;DR
You can get rid of NU1503 by including this in your .proj / msbuild file:
<!-- prevents NU1503 -->
<Target Name="_IsProjectRestoreSupported"
Returns="#(_ValidProjectsForRestore)">
<ItemGroup>
<_ValidProjectsForRestore Include="$(MSBuildProjectFullPath)" />
</ItemGroup>
</Target>
<Target Name="Restore" />
Source: https://github.com/NuGet/NuGet.Client/blob/537630019c99fdc7bed1b3dfdade72fc3e31692f/src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets#L1286-L1298
Detailed explanation
I figured this out by inspecting the msbuild.binlog file via dotnet restore /bl with the awesome MSBuild Binary Log File Viewer tool.
The warning is generated by the WarnForInvalidProjectTask:
... which are generated by the _FilterRestoreGraphProjectInputItems target...
... which calls a _IsProjectRestoreSupported target, if there is one.

Need help for creating msi file using wix with nant command line

I have one wix project file abv.wixproj and its product.wxs. I am able to generate its msi file by building it from Visual studio.
I would like to generate msi file using command (i.e. from .bat file).
I would like to generate msi file using nant. I got some code having <target> tag but not sure, in which file should I add this tag. should I create new file or in wsx file.
Kindly help me to share some example of nant commands to generate msi file using command line without Visual studio build
I have tried using "%WIX%bin\candle" *.wxs -o obj\ but it is giving below error
error CNDL0150 : Undefined preprocessor variable
I need one or more commands that will read wxs file and create msi or exe file by executing wix project
The .wixproj is an MSBuild project file. Just use the msbuild task from NAnt and let the targets files handle all the candle and light details for you.

Using FireGiant Appx Extension with cmake

I have a Windows application which is built using MSVC and packaged as an .MSI file using WiX. The whole build is managed by cmake and WiX is invoked using the CPackWIX module.
I am now trying to extend the build environment to also build an .APPX package. I am following the official documentation by FireGiant.
After installing the WiX Expansion Pack, I have added the extension FgAppxExtension.wixext by appending it to the variable CPACK_WIX_EXTENSIONS like so:
SET(CPACK_WIX_EXTENSIONS WixUtilExtension FgAppxExtension.wixext)
I have then edited the .wxs source code as indicated here.
The build runs without any errors but creates no .APPX package. It only creates the usual .MSI package. In the wix.log file I see the line:
"C:/Program Files (x86)/WiX Toolset v3.11/bin/light.exe" -nologo -out "F:/dev/MyApp-build/_CPack_Packages/win32/WIX/MyApp-1.15.0+115-default-eb4abec2e9d2+.msi" -ext "FgAppxExtension.wixext" -ext "WixUIExtension" -ext "WixUtilExtension" -cultures:de-DE;en-US "-loc" "C:/dev/MyApp/resources/packaging/win/WIX.Texts.de-DE.wxl" "-loc" "C:/dev/MyApp/resources/packaging/win/WIX.Texts.en-US.wxl" "F:/dev/MyApp-build/_CPack_Packages/win32/WIX/directories.wixobj" "F:/dev/MyApp-build/_CPack_Packages/win32/WIX/files.wixobj" "F:/dev/AusweisApp2-build/_CPack_Packages/win32/WIX/features.wixobj" "F:/dev/MyApp-build/_CPack_Packages/win32/WIX/main.wixobj"
for the .MSI file, but no line for the .APPX package.
The documentation says that after adding a reference to FgAppxExtension.wixext
... the build process will attempt to create AppX packages.
but this does not happen.
Note that adding a wrong extension in the cmake file will result in a build error.
Changing the .wxs source code without adding the extension will also result in an error:
The Product element contains an unhandled extension element 'fga:Appx'.
So I think the FgAppxExtension.wixext extension is loaded correctly, yet no .APPX package is built.
Do you have any hints?
Loading the FgAppxExtension.wixext extension isn't enough to build the .appx package while building the .msi package. FgAppxExtension does that using MSBuild, which isn't in play when using CMake.
When you're not using MSBuild, you can invoke the FireGiant.Appx.exe tool after Light.exe has produced the .msi and .wixpdb files.

MSBuild: ProjectReference Output Path in Wix Projects

I'm trying to get the Output folder of referenced project in my Wix Visual Studio project, using MsBuild task. But it is failing with following error:
C:\Program Files
(x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(724,5):
error : The OutputPath property is not set for project
'ConsoleApplicatio n1.csproj'. Please check to make sure that you
have specified a valid combination of Configuration and Platform for
this project. Configuration='Release' Platfo rm='x86'. You may be
seeing this message because you are trying to build a project without
a solution file, and have specified a non-default Configuration or
Plat form that doesn't exist for this project.
[C:\Users\fwaheed\Documents\Visual Studio
2015\Projects\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cspro
j]
Following is the Target calling MsBuild task.
<Target Name="AfterBuild">
<MSBuild
Projects="#(ProjectReference)"
Targets="GetTargetPath"
BuildInParallel="false"
Condition="'%(Name)'=='ConsoleApplication1'" >
<Output TaskParameter="TargetOutputs" ItemName="DependentAssemblies" />
</MSBuild>
</Target>
Please note that same target worked perfectly if it is CSharp project, but failing in Wix project.
Can someone guide how to get ReferencedProjects output dirs in Wix Projects?
Thanks
You can try to see how Wix does it for passing the reference values to candle on build. They're in the wix2010.targets or wix200x.targets file. Unfortunately I don't have the time to really dig into this stuff but the properties these tasks set should still exist to be used in your AfterBuild target.
Just search for "ResolveReferences" in one of those targets files.
You can also just try setting
<OutputPath>somepathhere</OutputPath>
in your csproj file since msbuild is complaining that the property isn't set.

MSBUILD error where folder contains more than one solution file

I'm trying to set up CCNET and I've run into a problem.
My builds are failing and I'm getting this error
MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file.
In my configuration file ccnet.config my msbuild block is as follows
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable>
<workingDirectory>C:\example\directory</workingDirectory>
<projectFile>ExampleSolution.sln</projectFile>
<buildArgs>/noconsolelogger /v:quiet
/p:Configuration=Debug
/p:ReferencePath="C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0\"
</buildArgs>
<targets>ReBuild</targets>
<timeout>600</timeout>
</msbuild>
In this case, C:\example\directory has multiple solution files. Even though I specified the project file I'm still getting that error.
You should specify what to build in the sln group.
msbuild SlnFolders.sln /t:NotInSolutionfolder:Rebuild;NewFolder\InSolutionFolder:Clean
So in CC.NET, add the /t parameter in the <buildArgs> tag.
Reference : http://msdn.microsoft.com/en-us/library/ms164311.aspx