Skip to content

Instantly share code, notes, and snippets.

@zhilich
Created November 8, 2017 22:37
Show Gist options
  • Save zhilich/962b79a04a13e5daebb49585c33d92b7 to your computer and use it in GitHub Desktop.
Save zhilich/962b79a04a13e5daebb49585c33d92b7 to your computer and use it in GitHub Desktop.
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
@author: Raman Zhylich ([email protected])
This project configures IISExpress in Visual Studio.
-->
<PropertyGroup>
<BuildDependsOn>
ConfigureIISExpress;
$(BuildDependsOn);
</BuildDependsOn>
<ApplicationHostConfig>$(SolutionDir).vs\config\applicationhost.config</ApplicationHostConfig>
</PropertyGroup>
<!-- Automatically configures IISExpress in Visual Studio. Updates virtual directory path in applicationhost.config to point to IISROOT -->
<Target Name="ConfigureIISExpress" Condition="Exists('$(ApplicationHostConfig)')">
<PropertyGroup>
<VirtualDirectoryPath>$([System.IO.Path]::GetFullPath('$(SolutionDir)..\IISROOT'))</VirtualDirectoryPath>
</PropertyGroup>
<FileUpdate Files="$(ApplicationHostConfig)"
Regex="physicalPath=&quot;[^&quot;]+&quot;"
ReplacementText="physicalPath=&quot;$(VirtualDirectoryPath)&quot;" />
<Touch Files="$(ApplicationHostConfig)" ContinueOnError="True" Time="01/01/2000" />
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment