The issue:
If I change the file extension from the visual studio, the file Build Action will be according to the previous Build Action and not according to the new file extension.
There is a way to enforce the visual studio always takes the Build Action from the file extension?
Example:
Create a new .Net Core 3.1 Class library. There is a single file (
Class1.cs) Thecsprojwill be like this:<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>netcoreapp3.1</TargetFramework> </PropertyGroup> </Project>Change the name of
Class1.cstoClass1.txtfrom the visual studio. The result,Class1.txtis withBuild ActionCompilealthough it is a text file. The content of csproj:
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>netcoreapp3.1</TargetFramework> </PropertyGroup> <ItemGroup> <None Remove="Class1.txt" /> </ItemGroup> <ItemGroup> <Compile Include="Class1.txt" /> </ItemGroup> </Project>
Additional information:
- I'm using Visual Studio 2019.
- If I change the file extension from the file system the issue doesn't appear.
Update:
A possible solution is to change the file Build Action after each file rename, but I want an automatic way.