Skip to content

Commit e541988

Browse files
authored
Make config transforms available in web deploy package (#44)
Proposal that make config transform files available in the web deploy package, and also continues have them "appear" nested underneath the main Web.config
1 parent afc4c08 commit e541988

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0"?>
2+
3+
<!-- For more information on using Web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=301874 -->
4+
5+
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
6+
<!--
7+
In the example below, the "SetAttributes" transform will change the value of
8+
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
9+
finds an attribute "name" that has a value of "MyDB".
10+
11+
<connectionStrings>
12+
<add name="MyDB"
13+
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
14+
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
15+
</connectionStrings>
16+
-->
17+
<system.web>
18+
<!--
19+
In the example below, the "Replace" transform will replace the entire
20+
<customErrors> section of your Web.config file.
21+
Note that because there is only one customErrors section under the
22+
<system.web> node, there is no need to use the "xdt:Locator" attribute.
23+
24+
<customErrors defaultRedirect="GenericError.htm"
25+
mode="RemoteOnly" xdt:Transform="Replace">
26+
<error statusCode="500" redirect="InternalError.htm"/>
27+
</customErrors>
28+
-->
29+
</system.web>
30+
</configuration>

src/MSBuild.SDK.SystemWeb/Sdk/MSBuild.SDK.SystemWeb.DefaultItems.props

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
<None Include="Web.BindingRedirects.config" Condition="EXISTS('Web.BindingRedirects.config')">
1616
<DependentUpon>Web.config</DependentUpon>
1717
</None>
18-
<Content Include="Web.*.config" Exclude="@(None)">
19-
<DependentUpon>Web.config</DependentUpon>
20-
</Content>
18+
19+
<!-- Altered web.*.config inclusion so these items will be in the WebDeploy Package
20+
Where they can be used at deployment time for Environment Specific Transformation
21+
https://github.com/CZEMacLeod/MSBuild.SDK.SystemWeb/issues/43
22+
-->
23+
<Content Include="Web.*.config" Exclude="@(None)" />
2124
</ItemGroup>
2225

2326
<!-- Support App_GlobalResources folder

src/MSBuild.SDK.SystemWeb/Sdk/Sdk.props

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@
1616
<ProjectCapability Include="LegacyRazorEditor" />
1717
</ItemGroup>
1818

19+
<!-- Support for making items "appear" nested in the solution explorer even when the DependentUpon metadata not set
20+
https://github.com/CZEMacLeod/MSBuild.SDK.SystemWeb/issues/43
21+
Added because desire to support Environment Specific Transformation of config files
22+
-->
23+
<ItemGroup
24+
Condition=" '$(BuildingInsideVisualStudio)' == 'true' and '$(VisualStudioVersion)' != '' and '$(VisualStudioVersion)' >= '15.0' "
25+
Label="This Capability is included by the .net core web projects and tells the solution Explorer to render certain items as nesting under others ">
26+
<ProjectCapability Include="DynamicFileNesting"/>
27+
</ItemGroup>
28+
1929
<Import Project="MSBuild.SDK.SystemWeb.DefaultPackages.props" />
2030
<!-- Default item includes -->
2131
<Import Project="MSBuild.SDK.SystemWeb.DefaultItems.props" />

0 commit comments

Comments
 (0)