Skip to content

Instantly share code, notes, and snippets.

@jtheisen
Last active October 3, 2022 02:43
Show Gist options
  • Save jtheisen/c7cd84d1c66598b045a360cca9ba8ef4 to your computer and use it in GitHub Desktop.
Save jtheisen/c7cd84d1c66598b045a360cca9ba8ef4 to your computer and use it in GitHub Desktop.
To be put in an AfterBuild task, it generates the necessary dummy files for ngen-ing a web application and gives the full shell commands to do it.
<!-- ngen -->
<Copy SourceFiles="$(MSBuildProjectDirectory)\Web.config" DestinationFiles="$(OutDir)$(AssemblyName).dummy.exe.config" />
<Copy SourceFiles="$(OutDir)$(AssemblyName).dll" DestinationFiles="$(OutDir)$(AssemblyName).dummy.exe" />
<GetFrameworkPath>
<Output
TaskParameter="Path"
PropertyName="FrameworkPath" />
</GetFrameworkPath>
<PropertyGroup>
<NgenUpdateCommand>&quot;$(FrameworkPath)\ngen.exe&quot; update</NgenUpdateCommand>
<NgenAbsoluteCommand>&quot;$(FrameworkPath)\ngen.exe&quot; install &quot;$(MSBuildProjectDirectory)\$(OutDir)\$(AssemblyName).dll&quot; &quot;/ExeConfig:$(MSBuildProjectDirectory)\$(OutDir)\$(AssemblyName).dummy.exe&quot;</NgenAbsoluteCommand>
<NgenRelativeCommand>&quot;$(FrameworkPath)\ngen.exe&quot; install &quot;$(OutDir)\$(AssemblyName).dll&quot; &quot;/ExeConfig:$(OutDir)\$(AssemblyName).dummy.exe&quot;</NgenRelativeCommand>
</PropertyGroup>
<Message Text="To ngen locally, run as admin: $(NgenAbsoluteCommand)" Importance="high" />
<Message Text="To ngen deployed, cd to deployment and run as admin: $(NgenRelativeCommand)" Importance="high" />
<Message Text="In both cases, subsequence updates can also be achieved with the longer-runnning update command: $(NgenUpdateCommand)" Importance="high" />
<!-- /ngen -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment