Skip to content

Duplicated json/config files being evaluated in VS for Mac for 3.1 #17088

@rodrmoya

Description

@rodrmoya

Describe the bug

With 3.1 installed, VS for Mac shows duplicated .json files in the project tree (see https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1005277). After some debugging, indeed, we are getting duplicated items for launchSettings.json, appsettings.json on ASP.NET Core projects.

To Reproduce

  1. Install only 3.0 and create a ASP.NET Core project and open it in VS for Mac -> no duplicated .json files
  2. Install 3.1 on top and open the same project (or create a new one) in VS for Mac -> duplicated .json files

After some investigation, found out this:

$ diff -u /usr/local/share/dotnet/sdk/3.0.100/Sdks/Microsoft.NET.Sdk.Razor/Sdk/Sdk.Razor.StaticAssets.ProjectSystem.props /usr/local/share/dotnet/sdk/3.1.100-preview3-014638/Sdks/Microsoft.NET.Sdk.Razor/Sdk/Sdk.Razor.StaticAssets.ProjectSystem.props
--- /usr/local/share/dotnet/sdk/3.0.100/Sdks/Microsoft.NET.Sdk.Razor/Sdk/Sdk.Razor.StaticAssets.ProjectSystem.props    2019-09-14 22:59:50.000000000 +0200
+++ /usr/local/share/dotnet/sdk/3.1.100-preview3-014638/Sdks/Microsoft.NET.Sdk.Razor/Sdk/Sdk.Razor.StaticAssets.ProjectSystem.props    2019-11-03 17:25:58.000000000 +0100
@@ -28,8 +28,13 @@
   <ItemGroup Condition="'$(EnableDefaultItems)' == 'true' And '$(EnableDefaultContentItems)' == 'true' ">
     <!-- Publish everything under wwwroot, all JSON files, all config files and all Razor files -->
     <Content Include="wwwroot\**" ExcludeFromSingleFile="true" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
-    <Content Include="**\*.config" ExcludeFromSingleFile="true" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);$(DefaultWebContentItemExcludes)" />
-    <Content Include="**\*.json" ExcludeFromSingleFile="true" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);$(DefaultWebContentItemExcludes)" />
+
+    <Content Include="**\*.config" ExcludeFromSingleFile="true" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);$(DefaultWebContentItemExcludes)" Condition="'$(ExcludeConfigFilesFromBuildOutput)'!='true'" />
+    <Content Include="**\*.json" ExcludeFromSingleFile="true" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);$(DefaultWebContentItemExcludes)" Condition="'$(ExcludeConfigFilesFromBuildOutput)'!='true'" />
+
+    <!-- When ExcludeConfigFilesFromBuildOutput is set, do not copy .,config, .json files to the build output directory. -->
+    <Content Include="**\*.config" ExcludeFromSingleFile="true" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);$(DefaultWebContentItemExcludes)" Condition="'$(ExcludeConfigFilesFromBuildOutput)'=='true'" />
+    <Content Include="**\*.json" ExcludeFromSingleFile="true" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);$(DefaultWebContentItemExcludes)" Condition="'$(ExcludeConfigFilesFromBuildOutput)'=='true'" />
 
     <!-- Set CopyToPublishDirectory to Never for items under AppDesignerFolder ("Properties", by default) to avoid publishing launchSettings.json -->
     <Content Update="$(AppDesignerFolder)\**" CopyToPublishDirectory="Never" Condition="'$(AppDesignerFolder)' != ''"/>

If I remove the last 3 lines added (starting in <!-- When ExcludeConfigFilesFromBuildOutput ...) everything works as expected in VS for Mac, no duplicated .json files.

Talking with @javiercn he mentioned this -> dotnet/razor#1240 which is where this change was added.

Further technical details

  • ASP.NET Core version -> 3.1
  • Include the output of dotnet --info
$ dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.1.100
 Commit:    fb9d6e244b

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.15
 OS Platform: Darwin
 RID:         osx.10.15-x64
 Base Path:   /usr/local/share/dotnet/sdk/3.1.100/

Host (useful for support):
  Version: 3.1.0
  Commit:  b7dc9ed2f7

.NET Core SDKs installed:
  3.1.100 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.1.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and it's version -> VS4Mac 8.4 Preview

Metadata

Metadata

Assignees

Labels

area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesinvestigate

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions