Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some msbuild magic to deploy dependent ASP.NET Core app #3

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions IISCrossover.Deploy.targets
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project>
<PropertyGroup>
<DisableFastUpToDateCheck Condition="'$(BuildingInsideVisualStudio)' == 'true' ">true</DisableFastUpToDateCheck>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="@(DeployProjectReference)">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
Expand All @@ -23,7 +27,7 @@
<Error Condition="$(_IsInvalidValidDeployProjects)" Text="Only a single DeployProjectReference node is allowed per project" />
</Target>

<Target Name="AssignDeployedProjectTargetPaths" BeforeTargets="AssignTargetPaths">
<Target Name="AssignDeployedProjectTargetPaths" BeforeTargets="AddDeployedProjectsToWebConfig">
<ItemGroup>
<_DeployedProjectOutput Update="@(_DeployedProjectOutput)">
<TargetPath>projects\%(_DeployedProjectOutput.DeployName)\$([System.IO.Path]::GetFileName('%(Identity)'))</TargetPath>
Expand Down Expand Up @@ -54,30 +58,39 @@
</ItemGroup>
</Target>

<Target Name="AddDeployedProjectsToWebConfig" AfterTargets="AssignDeployedProjectTargetPaths">
<Target Name="PrepareDeployProjectPaths" BeforeTargets="AddDeployedProjectsToWebConfig">
<PropertyGroup>
<__DeployedProjectTransformPath>$(IntermediateOutputPath)deployed_transform.xml</__DeployedProjectTransformPath>
<__WebConfigPath>web.config</__WebConfigPath>
<__IsPublishing>false</__IsPublishing>
<__IsPublishing Condition=" '$(PublishProfile)' != '' ">true</__IsPublishing>
</PropertyGroup>

<ItemGroup>
<_DeployProjectPaths Include="$(OutDir)%(_DeployedProjectOutput.TargetPath)">
<HostingModel>%(_DeployedProjectOutput.HostingModel)</HostingModel>
<ContentRoot>$([System.IO.Path]::GetDirectoryName(%(_DeployedProjectOutput.OriginalItemSpec)))</ContentRoot>
<TargetDirectory>$([System.IO.Path]::GetDirectoryName(%(_DeployedProjectOutput.TargetPath)))</TargetDirectory>
</_DeployProjectPaths>
<_DeployProjectPaths Condition="$(__IsPublishing)" Update="@(_DeployProjectPaths)">
<ContentRoot>%(TargetDirectory)</ContentRoot>
</_DeployProjectPaths>
<_DeployProjectPaths Update="@(_DeployedProjectOutput)" Condition=" '%(HostingModel)' == '' ">
<HostingModel>outofprocess</HostingModel>
twsouthwick marked this conversation as resolved.
Show resolved Hide resolved
</_DeployProjectPaths>
</ItemGroup>

<Error Text="Unknown hosting model: %(_DeployProjectPaths.HostingModel)" Condition=" '%(_DeployProjectPaths.HostingModel)' != 'outofprocess' AND '%(_DeployProjectPaths.HostingModel)' != 'inprocess' " />
</Target>

<Target Name="AddDeployedProjectsToWebConfig" BeforeTargets="AssignTargetPaths">
<ItemGroup>
<__DeployedProjectTransformLines Include='&lt;configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"&gt;' />
<__DeployedProjectTransformLines Include="&lt;system.webServer&gt;" />
<!-- In order to remove, we must have a node. So, we'll add one if it's not there and then remove it. If there were 'RemoveIfExists' we could just use that -->
<__DeployedProjectTransformLines Include='&lt;aspNetCore xdt:Transform="InsertIfMissing" /&gt;' />
<__DeployedProjectTransformLines Include='&lt;aspNetCore xdt:Transform="Remove" /&gt;' />
<__DeployedProjectTransformLines Include='&lt;aspNetCore processPath="dotnet" arguments="%(_DeployProjectPaths.Identity)" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="%(_DeployProjectPaths.HostingModel)" xdt:Transform="Insert" /&gt;' />
<__DeployedProjectTransformLines Include='&lt;aspNetCore processPath="dotnet" arguments="%(_DeployProjectPaths.Identity) --contentRoot %(_DeployProjectPaths.ContentRoot)" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="%(_DeployProjectPaths.HostingModel)" xdt:Transform="Insert" /&gt;' />
<__DeployedProjectTransformLines Include="&lt;/system.webServer&gt;" />
<__DeployedProjectTransformLines Include="&lt;/configuration&gt;" />
</ItemGroup>
Expand Down
57 changes: 31 additions & 26 deletions LegacyApi/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,59 @@
-->
<configuration>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Triggered! 😄

<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="webpages:Version" value="3.0.0.0"/>
<add key="webpages:Enabled" value="false"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.7.2" />
<httpRuntime targetFramework="4.7.2" />
<compilation debug="true" targetFramework="4.7.2"/>
<httpRuntime targetFramework="4.7.2"/>
</system.web>
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="CSS" path="*.css" verb="*" type="System.Web.Handlers.TransferRequestHandler" modules="AspNetCoreModuleV2" preCondition="integratedMode,runtimeVersionv4.0" />
<add name="Pages" path="*.aspx" verb="*" type="System.Web.Handlers.TransferRequestHandler" modules="AspNetCoreModuleV2" preCondition="integratedMode,runtimeVersionv4.0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" modules="AspNetCoreModuleV2" preCondition="integratedMode,runtimeVersionv4.0" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0"/>
<remove name="OPTIONSVerbHandler"/>
<remove name="TRACEVerbHandler"/>
<add name="CSS" path="*.css" verb="*" type="System.Web.Handlers.TransferRequestHandler" modules="AspNetCoreModuleV2"
preCondition="integratedMode,runtimeVersionv4.0"/>
<add name="Pages" path="*.aspx" verb="*" type="System.Web.Handlers.TransferRequestHandler" modules="AspNetCoreModuleV2"
preCondition="integratedMode,runtimeVersionv4.0"/>
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" modules="AspNetCoreModuleV2"
preCondition="integratedMode,runtimeVersionv4.0"/>
</handlers>
<aspNetCore processPath="dotnet" arguments="bin\projects\Greenfield\Greenfield.dll --contentRoot ..\Greenfield" stdoutLogEnabled="true"
stdoutLogFile=".\logs\stdout" hostingModel="outofprocess"/>
twsouthwick marked this conversation as resolved.
Show resolved Hide resolved
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f"/>
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed"/>
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand Down