Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# - Use of wildcards inside csproj file and new files addition

Inside .csproj files Visual Studio and Xamarin Studio as default keep a reference to every file used inside the project.

<ItemGroup>
    <Compile Include="Utils\Foo1Utils.cs" />
    <Compile Include="Utils\Foo2Utils.cs" />
    <Compile Include="Services\FooService.cs" />
    ...
</ItemGroup>

To avoid conflicts on csproj files inside our solution at every file addition, we started to use wildcards:

<ItemGroup>
    <Compile Include="Utils\*.cs" />
    <Compile Include="Services\*.cs" />
    ...
</ItemGroup>

The problem is that apparently both on Visual Studio and Xamarin Studio is not possible to "explain" to the IDE that we are using wildcards, and when we add a new file to the project they add a new reference to the file ignoring the wildcard *.cs on the folder. It's still a good solution because we don't need to commit our .csproj at every file addition, but now we have to reset them each time... anyone knows if there is a solution?

EDIT: with Rider (JetBrains) there isn't this problem, if in the csproj there is a wildcard and I add a new file everything works fine.

like image 928
Mauro Piccotti Avatar asked Mar 23 '17 15:03

Mauro Piccotti


1 Answers

If you use the new format for projects (.net core 2) it will use wildcard includes without you having to specify it for files in the project folder. You can manually set the target framework in order to still compile to whatever target you want.

like image 128
ozzymcduff Avatar answered Oct 15 '22 00:10

ozzymcduff