Failure publishing WPF app with RID can fail if intermediate path is overridden
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
**Repro steps**
- `dotnet new wpf`
- Put the following in `Directory.Build.props` in project directory:
```xml
$(MSBuildProjectDirectory)/out/$(MSBuildProjectName)/bin
$(MSBuildProjectDirectory)/out/$(MSBuildProjectName)/obj
```
- `dotnet build`
- `dotnet publish -r win10-x64 --self-contained`
**Expected result**
Publish succeeds
**Actual result**
Errors such as:
> out\wpf\obj\Debug\netcoreapp3.0\wpf_oqgucux2_wpftmp.AssemblyInfo.cs(10,12): error CS0579: Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute [C:\git\repro\wpf\wpf_xfkwhwdg_wpftmp.csproj]
out\wpf\obj\Debug\netcoreapp3.0\wpf_oqgucux2_wpftmp.AssemblyInfo.cs(11,12): error CS0579: Duplicate 'System.Reflection.AssemblyConfigurationAttribute' attribute [C:\git\repro\wpf\wpf_xfkwhwdg_wpftmp.csproj]
It looks like these errors are due to the generated files being generated in two separate paths (one from the RID-less `dotnet build`, and the other from the `dotnet publish` with the RID specified), but both are being included in the WPF temporary generated project (likely because the Directory.Build.props intermediate path depends on the project name, which changes for the temporary project).
The best fix is probably to stop generating a temporary project, and instead call a target in the main project, if that's possible.
FYI @nguerrera
Thanks to @mjrousos for reporting this
Contributor guide
Assessment
This issue has not been assessed yet.