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