withSupportedRuntime.config files generated for exe type projects after migration to SDK style

JP 1 Reputation point
2022-08-09T21:33:31.193+00:00

We are in the middle of transition from old style to SDK style for our projects. We noticed that for exe types, msbuild will generate additional file apart of exe and exe.config. Because of that our integration pipelin will fail as they will not expect such files to be produced. File end with "*.withSupportedRuntime.config". There doesn't seems to be much info what this file do in addition to exe.config. Do we really need those files to be deployed with our .NET Framework binaries. I assume not as those was not required before.. And most importantly. Can we stop msbuild generating them ? And if yes, how we can do it.

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
36,213 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JP 1 Reputation point
    2022-08-24T15:49:56.533+00:00

    We found root cost for this issue. Our project contains many *.config files which in majority cases should be copied to target directories. And therefore they are configured as "content" and <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>. To avoid listing and redefining every single config file in project which this attributes we added following config to project.
    <Content Include="***.config">
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>

    Based on Microsoft SDK style project documentation. By default obj and bin folder are excluded from this rules (https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview). However when such project is loaded over Microsoft.Build.Evaluation.Project fthose files will be listed as project item with Content\PreserveNewest as this class is ignoring DefaultItemExcludes locations and therefore files are incorrectly considered as content of project files. We will be raising bug for Microsoft.Build.Evaluation.

    0 comments No comments