dotnet / dotnet/wpf

UseArtifactsOutput breaks multi-target WPF build

Open
#9,556 6 comments 4 reactions 0 assignees View on GitHub
Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

Combining `TargetFrameworks` and `UseArtifactsOutput` breaks the **Rebuild** task. A regular **Build** succeeds.
```
Rebuild started at 14:16...
1>------ Rebuild All started: Project: WpfBuildError, Configuration: Debug Any CPU ------
Restored C:\source\WpfBuildError\WpfBuildError\WpfBuildError.csproj (in 2 ms).
1>CSC : error CS2012: Cannot open 'C:\source\WpfBuildError\artifacts\obj\WpfBuildError\debug_\WpfBuildError.dll' for writing -- 'The process cannot access the file 'C:\source\WpfBuildError\artifacts\obj\WpfBuildError\debug_\WpfBuildError.dll' because it is being used by another process.'
1>Done building project "WpfBuildError_1hckbbpn_wpftmp.csproj" -- FAILED.
1>WpfBuildError -> C:\source\WpfBuildError\artifacts\bin\WpfBuildError\debug_net6.0-windows\WpfBuildError.dll
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
========== Rebuild completed at 14:16 and took 04,746 seconds ==========
```

Two properties are needed to encounter this bug:

**WpfBuildError.csproj**
```xml
net6.0-windows;net8.0-windows
```
**Directory.Build.props**
```xml
true
```

### Reproduction Steps

1) Open sample project: [WpfBuildError.zip](https://github.com/user-attachments/files/16581563/WpfBuildError.zip)
2) **Rebuild** the solution. (A regular Build succeeds.)

### Expected behavior

The project should compile.

### Actual behavior

The project dos not compile.

### Regression?

_No response_

### Known Workarounds

Don't set `UseArtifactsOutput` (and be very unhappy about the artifact mess on disk)...

### Impact

We cannot update our projects to `.NET 8` since we need some consuming systems to target `.NET 6`. Basically, this is a showstopper.

Any workaround is very much appreciated!

### Configuration

Running `Visual Studio 17.10.3` and the bundled `.NET SDK 8.0.302`.

### Other information

_No response_

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.