Last active
February 21, 2022 07:22
-
-
Save dasMulli/33beffa15deb1caef373f5b8499082a2 to your computer and use it in GitHub Desktop.
Demo wix project to publish a self-contained .NET Core app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<PropertyGroup> | |
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> | |
<ProductVersion>3.10</ProductVersion> | |
<ProjectGuid>91e4dc15-312a-4e90-bc1c-01de5dc99447</ProjectGuid> | |
<SchemaVersion>2.0</SchemaVersion> | |
<OutputName>CoreConsoleAppSetup</OutputName> | |
<OutputType>Package</OutputType> | |
<DefineSolutionProperties>false</DefineSolutionProperties> | |
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath> | |
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath> | |
</PropertyGroup> | |
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> | |
<OutputPath>bin\$(Configuration)\</OutputPath> | |
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath> | |
<DefineConstants>Debug</DefineConstants> | |
</PropertyGroup> | |
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> | |
<OutputPath>bin\$(Configuration)\</OutputPath> | |
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath> | |
</PropertyGroup> | |
<ItemGroup> | |
<Compile Include="Product.wxs" /> | |
</ItemGroup> | |
<ItemGroup> | |
<ProjectReference Include="..\src\CoreConsoleApp\CoreConsoleApp.xproj"> | |
<Name>CoreConsoleApp</Name> | |
<Project>{d6d08e89-e6ed-47bd-bf04-c149d2057970}</Project> | |
<Private>True</Private> | |
<DoNotHarvest>True</DoNotHarvest> | |
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups> | |
<RefTargetDir>INSTALLFOLDER</RefTargetDir> | |
<IsDotnetSDKProject>True</IsDotnetSDKProject> | |
<TargetFrameworkIdentifier>netcoreapp1.0</TargetFrameworkIdentifier> | |
<Runtime>win7-x64</Runtime> | |
</ProjectReference> | |
</ItemGroup> | |
<Import Project="$(WixTargetsPath)" /> | |
<Target Name="BeforeBuild"> | |
<Exec WorkingDirectory="%(ProjectReference.RootDir)%(ProjectReference.Directory)" Command="dotnet publish -c $(Configuration) -f %(ProjectReference.TargetFrameworkIdentifier) -r %(ProjectReference.Runtime)" Condition="'%(ProjectReference.IsDotnetSDKProject)' == 'True'" /> | |
<ItemGroup> | |
<LinkerBindInputPaths Include="%(ProjectReference.RootDir)%(ProjectReference.Directory)bin\$(Configuration)\%(ProjectReference.TargetFrameworkIdentifier)\%(ProjectReference.Runtime)\publish" /> | |
</ItemGroup> | |
<HeatDirectory | |
DirectoryRefId="INSTALLFOLDER" | |
OutputFile="obj\$(Configuration)\%(ProjectReference.Name).wxs" | |
Directory="%(ProjectReference.RootDir)%(ProjectReference.Directory)bin\$(Configuration)\%(ProjectReference.TargetFrameworkIdentifier)\%(ProjectReference.Runtime)\publish" | |
ComponentGroupName="SourceComponentGroup" | |
ToolPath="$(WixToolPath)" | |
AutogenerateGuids="true" | |
SuppressCom="True" | |
SuppressRegistry="True" | |
SuppressFragments="true" | |
SuppressRootDirectory="true" | |
Condition="'%(ProjectReference.IsDotnetSDKProject)' == 'True'"/> | |
<ItemGroup> | |
<Compile Include="obj\$(Configuration)\%(ProjectReference.Name).wxs" Condition="'%(ProjectReference.IsDotnetSDKProject)' == 'True'" /> | |
</ItemGroup> | |
</Target> | |
<!-- | |
To modify your build process, add your task inside one of the targets below and uncomment it. | |
Other similar extension points exist, see Wix.targets. | |
<Target Name="AfterBuild"> | |
</Target> | |
--> | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> | |
<Product Id="*" Name="CoreConsoleAppSetup" Language="1033" Version="1.0.0.0" Manufacturer="Martin" UpgradeCode="5f5ea8c6-7584-4bf7-a935-1ec77a688106"> | |
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" /> | |
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> | |
<MediaTemplate EmbedCab="yes" /> | |
<Feature Id="ProductFeature" Title="CoreConsoleAppSetup" Level="1"> | |
<ComponentGroupRef Id="ProductComponents" /> | |
</Feature> | |
</Product> | |
<Fragment> | |
<Directory Id="TARGETDIR" Name="SourceDir"> | |
<Directory Id="ProgramFilesFolder"> | |
<Directory Id="INSTALLFOLDER" Name="CoreConsoleAppSetup" /> | |
</Directory> | |
</Directory> | |
</Fragment> | |
<Fragment> | |
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER"> | |
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. --> | |
<!-- <Component Id="ProductComponent"> --> | |
<!-- TODO: Insert files, registry keys, and other resources here. --> | |
<!-- </Component> --> | |
<ComponentGroupRef Id="SourceComponentGroup" /> | |
</ComponentGroup> | |
</Fragment> | |
</Wix> |
that was during .net core 1.0/1.1 timeframe..
Not sure this is a good way to do it anymore with new csproj - you may get NuGet errors (assets file) or something crazy.
I worked on another project where I built targets into a project that made the project to publish emit its publish output via a normal project-to-project reference (so you basically add a reference and you'll get the publish output in a subdirectory in your bin
folder) that could be reused here. it's more difficult though.. you can find it at https://github.com/dasMulli/AssemblyInfoGenerationSdk/blob/7b5529abf6a86be3ed7302db438e0733e86959c9/src/DasMulli.AssemblyInfoGeneration.Sdk/sdk-layout.targets
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @dasMulli,
Thanks for sharing this. Can you please tell me what version of WiX and dontet you tested this on? I am trying with WiX 3.14 and dotnet 2.1 and I seem to get errors :(