I have noticed a minor difference in behavior between Visual Studio 2017 and Visual Studio 2019. When I open a solution with VS 2017 it will automatically create folders that are mentioned in the project files (e.g. <Folder Include="Data\">
in a .csproj
file). Visual Studio 2019 won't do that though. Is there a way to change this behavior in Visual Studio 2019 so that it too creates those folders if they don't exist?
EDIT: I first noticed this problem in combination with TFVC. When other people add empty folders to their solution it gets added to the .csproj file but when checking it in the empty folder is ignored. When I get that project from TFVC and open it with VS 2017 the folders are automatically created but not with VS 2019.
I would like these folders to be created since the person checking them in expected them to be there. TFVC can't work with empty folders, so it seemed good to me that VS 2017 solved the problem. Unfortunately VS 2019 seems to behave slightly differently.
To reproduce:
- Create a c# Class library (.NET framework) version 4.7.2 project in Visual Studio 2017 or 2019
- Close the solution and edit the .csproj file
- Add An ItemGroup with folders that don't exist. The end result might look like something like this:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>81fa1651-0a21-4ed6-8626-763141ab67cf</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TestDotNetFramework</RootNamespace>
<AssemblyName>TestDotNetFramework</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System"/>
<Reference Include="System.Core"/>
<Reference Include="System.Xml.Linq"/>
<Reference Include="System.Data.DataSetExtensions"/>
<Reference Include="Microsoft.CSharp"/>
<Reference Include="System.Data"/>
<Reference Include="System.Net.Http"/>
<Reference Include="System.Xml"/>
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<!-- I added these manually -->
<ItemGroup>
<Folder Include="TestFolder\" />
<Folder Include="TestFolder2\Testing\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
- Save the .csproj file
- Open the solution with Visual Studio 2017. You will see that the folders you added in the ItemGroup are created automatically.
- Remove those folders and open the solution with Visual Studio 2019. The folders are not created automatically.