Skip to content

Instantly share code, notes, and snippets.

@roozbehid
Last active July 15, 2024 21:07
Show Gist options
  • Select an option

  • Save roozbehid/f30d111cd38656e7f185034083451ede to your computer and use it in GitHub Desktop.

Select an option

Save roozbehid/f30d111cd38656e7f185034083451ede to your computer and use it in GitHub Desktop.
MSBuild, csproj hack to auto generate wxs file for wix for general dependencies like Microsoft dlls and such
<!--
I found this way somethimes saves you good chunk of time
-->
<Target Name="Createwxs" AfterTargets="AfterBuild">
<ItemGroup>
<MicrosoftDlls Include="$(OutputPath)\Microsoft.*.*" />
<MicrosoftDlls Include="$(OutputPath)\System.*.*" />
<MicrosoftDlls Include="$(OutputPath)\JWT*.*" />
<MicrosoftDlls Include="$(OutputPath)\Swashbuckle.*.*" />
<Line Include="line01">
<Text>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</Text>
</Line>
<Line Include="line02">
<Text>&lt;Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"&gt; </Text>
</Line>
<Line Include="line03">
<Text>
&lt;Fragment&gt;
</Text>
</Line>
<Line Include="line04">
<Text>
&lt;DirectoryRef Id="TARGETDIR"&gt;
</Text>
</Line>
<Line Include="line05">
<Text>
&lt;Component Id="MyComponent" Guid="{12DE2CE3-DF71-3E8C-8BC0-111111112345}"&gt;
</Text>
</Line>
<Line Include="line06">
<Text> &lt;File Name="%(MicrosoftDlls.Filename)%(MicrosoftDlls.Extension)" Source="%(MicrosoftDlls.Identity)" /&gt;</Text>
</Line>
<Line Include="line07">
<Text> &lt;/Component&gt; </Text>
</Line>
<Line Include="line08">
<Text> &lt;/DirectoryRef&gt; </Text>
</Line>
<Line Include="line09">
<Text> &lt;/Fragment&gt; </Text>
</Line>
<Line Include="line10">
<Text>&lt;/Wix&gt;</Text>
</Line>
<LineText Include="%(Line.Text)" />
</ItemGroup>
<WriteLinesToFile File="MyComponent.wxs" Lines="@(LineText)" Overwrite="true" />
</Target>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment