In an earlier post, I detailed how I converted a personal project across to the new csproj file format - it turns out that I made a few mistakes in the process.

One of the benefits of the new file format is that we no longer need to explicitly list every single source file. We can use wildcards like this:

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

But, instead of supplying wildcards explicitly, there’s a better way - the tooling includes default rules.

Remove the wildcard elements shown above and check to see if you have a <EnableDefaultCompileItems> element. If you do, either delete it (recommended), or change the value to true.

I discovered this when my builds started throwing some odd errors = like this one:

Warning    CS2002
Source file 'TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs' specified multiple times

The source of my problem was trying to use the new .csproj file-format for a WPF project - that’s not currently supported and doesn’t seem to work. Fixing the inclusion rules didn’t fix that problem, unfortunately.

Comments

blog comments powered by Disqus
Next Post
Basic validation  21 Jul 2018
Prior Post
Why we need better validation  07 Jul 2018
Related Posts
Using Constructors  27 Feb 2023
An Inconvenient API  18 Feb 2023
Method Archetypes  11 Sep 2022
A bash puzzle, solved  02 Jul 2022
A bash puzzle  25 Jun 2022
Improve your troubleshooting by aggregating errors  11 Jun 2022
Improve your troubleshooting by wrapping errors  28 May 2022
Keep your promises  14 May 2022
When are you done?  18 Apr 2022
Fixing GitHub Authentication  28 Nov 2021
Archives
July 2018
2018