Skip to content

Commit 32f72db

Browse files
authored
Allows the Visual Studio Settings Designer to read from and write to Web.config (#97)
# Summary Closes #95 - where opening or using the Settings Designer in Visual Studio creates a new `App.config` and writes settings there, instead of using `Web.config`. # What this change does When `App.config` does not exist, we link `Web.config` as `App.config` (hidden & not part of the project) so the designer "finds" an `App.config`, but actually reads/writes `Web.config`. # Rationale The .NET Settings Designer expects `App.config`. In Web projects that only have `Web.config`, the designer creates a new `App.config` and starts using it, which is undesirable for ASP.NET. By linking `Web.config` as `App.config` (keeping it out of Solution Explorer to avoid clutter), the designer stays happy and all settings end up in Web.config, without leaving behind a stray `App.config`. # Behavior & edge cases - If `App.config` already exists: nothing changes; we do not add the linked item - If `Web.config` is missing: nothing changes; no link is added #Manual verification steps - Create an SDK-style ASP.NET 4.x project with only Web.config (no App.config) - e.g. dotnet new -i systemwebfull - Open in Visual Studio -> Project Properties -> Settings -> "Create or open application settings" - Add a new setting - Expected: VS Settings Designer writes to `Web.config`; no `App.config` file is created on disk or added to the project - Add a real `App.config` and repeat - Expected: the SDK does not add the link, designer uses the existing App.config (no behavior change from today) #Backwards compatibility Fully backwards compatible: - Projects already using App.config are unaffected - Projects with only Web.config get the desired designer behavior
1 parent 6aabca7 commit 32f72db

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@
3131
https://github.com/CZEMacLeod/MSBuild.SDK.SystemWeb/issues/43
3232
-->
3333
<Content Include="Web.*.config" Exclude="@(None)" />
34+
35+
<!-- Allows the Visual Studio Settings Designer to read from and write to Web.config
36+
https://github.com/CZEMacLeod/MSBuild.SDK.SystemWeb/issues/95
37+
-->
38+
<None Include="Web.config" Condition="EXISTS('Web.config') AND !EXISTS('App.config')">
39+
<Link>App.config</Link>
40+
<Visible>false</Visible>
41+
<InProject>false</InProject>
42+
</None>
3443
</ItemGroup>
3544

3645
<!-- Support App_GlobalResources folder

0 commit comments

Comments
 (0)