dotnet / dotnet/wpf

Failure publishing WPF app with RID can fail if intermediate path is overridden

Open
#366 7 comments 1 reaction 0 assignees View on GitHub
Bug
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.