-
Notifications
You must be signed in to change notification settings - Fork 14
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
twsouthwick
wants to merge
7
commits into
davidfowl:master
Choose a base branch
from
twsouthwick:msbuild-magic
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1df4238
Add some msbuild magic to deploy dependent ASP.NET Core app
twsouthwick 32c9869
Filter deployed projects
twsouthwick 8213b24
Add checks for only a single deploy
twsouthwick 076fc17
Merge remote-tracking branch 'origin/master' into msbuild-magic
twsouthwick 9a887d5
Include web.config
twsouthwick 0df1e7f
Update IISCrossover.Deploy.targets
twsouthwick a879bb1
Change to inprocess
twsouthwick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<DisableFastUpToDateCheck Condition="'$(BuildingInsideVisualStudio)' == 'true' ">true</DisableFastUpToDateCheck> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="@(DeployProjectReference)"> | ||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly> | ||
<OutputItemType>_DeployedProjectOutput</OutputItemType> | ||
<CopyToOutputDirectory>Never</CopyToOutputDirectory> | ||
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties> | ||
<DeployName>$([System.IO.Path]::GetFileNameWithoutExtension(%(Identity)))</DeployName> | ||
<Private>false</Private> | ||
</ProjectReference> | ||
</ItemGroup> | ||
|
||
<Target Name="VerifyOnlyOneDeployedProject" BeforeTargets="AssignDeployedProjectTargetPaths"> | ||
<PropertyGroup> | ||
<_IsInvalidValidDeployProjects>false</_IsInvalidValidDeployProjects> | ||
<_HasDeployProject>true</_HasDeployProject> | ||
<_HasDeployProject Condition=" '@(DeployProjectReference->Count())' == '0' " >false</_HasDeployProject> | ||
<_HasOneDeployProject>false</_HasOneDeployProject> | ||
<_HasOneDeployProject Condition=" '@(DeployProjectReference->Count())' == '1' " >true</_HasOneDeployProject> | ||
<_IsInvalidValidDeployProjects Condition="!$(_HasDeployProject) AND !$(_HasOneDeployProject)">true</_IsInvalidValidDeployProjects> | ||
</PropertyGroup> | ||
|
||
<Error Condition="$(_IsInvalidValidDeployProjects)" Text="Only a single DeployProjectReference node is allowed per project" /> | ||
</Target> | ||
|
||
<Target Name="AssignDeployedProjectTargetPaths" BeforeTargets="AddDeployedProjectsToWebConfig"> | ||
<ItemGroup> | ||
<_DeployedProjectOutput Update="@(_DeployedProjectOutput)"> | ||
<TargetPath>projects\%(_DeployedProjectOutput.DeployName)\$([System.IO.Path]::GetFileName('%(Identity)'))</TargetPath> | ||
</_DeployedProjectOutput> | ||
</ItemGroup> | ||
|
||
<MSBuild | ||
Projects="@(_MSBuildDeployProjectReferenceExistent)" | ||
Targets="PublishItemsOutputGroup" | ||
BuildInParallel="$(BuildInParallel)" | ||
Properties="%(_MSBuildDeployProjectReferenceExistent.SetConfiguration); %(_MSBuildDeployProjectReferenceExistent.SetPlatform); %(_MSBuildDeployProjectReferenceExistent.SetTargetFramework)" | ||
Condition="'%(_MSBuildDeployProjectReferenceExistent.DeployName)' != '' " | ||
ContinueOnError="$(ContinueOnError)" | ||
SkipNonexistentTargets="true" | ||
RemoveProperties="%(_MSBuildDeployProjectReferenceExistent.GlobalPropertiesToRemove)$(_GlobalPropertiesToRemoveFromProjectReferences)"> | ||
|
||
<Output TaskParameter="TargetOutputs" ItemName="_DeployedProjectsContents"/> | ||
</MSBuild> | ||
|
||
<ItemGroup> | ||
<_AllDeployedProjectFilesContent Include="@(_DeployedProjectsContents)"> | ||
<TargetPath>projects\%(_DeployedProjectsContents.DeployName)\%(_DeployedProjectsContents.TargetPath)</TargetPath> | ||
</_AllDeployedProjectFilesContent> | ||
<_AllDeployedProjectFilesContent Include="@(_DeployedProjectOutput)" /> | ||
<Content Include="@(_AllDeployedProjectFilesContent)"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
</Target> | ||
|
||
<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>inprocess</HostingModel> | ||
</_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='<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">' /> | ||
<__DeployedProjectTransformLines Include="<system.webServer>" /> | ||
<!-- 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='<aspNetCore xdt:Transform="InsertIfMissing" />' /> | ||
<__DeployedProjectTransformLines Include='<aspNetCore xdt:Transform="Remove" />' /> | ||
<__DeployedProjectTransformLines Include='<aspNetCore processPath="dotnet" arguments="%(_DeployProjectPaths.Identity) --contentRoot %(_DeployProjectPaths.ContentRoot)" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="%(_DeployProjectPaths.HostingModel)" xdt:Transform="Insert" />' /> | ||
<__DeployedProjectTransformLines Include="</system.webServer>" /> | ||
<__DeployedProjectTransformLines Include="</configuration>" /> | ||
</ItemGroup> | ||
|
||
<WriteLinesToFile File="$(__DeployedProjectTransformPath)" Lines="@(__DeployedProjectTransformLines)" Overwrite="true" WriteOnlyWhenDifferent="true" /> | ||
|
||
<TransformXml Source="$(__WebConfigPath)" Transform="$(__DeployedProjectTransformPath)" Destination="$(__WebConfigPath)" /> | ||
</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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Triggered! 😄