IntermediateOutputPath absolute path causes exe to be overwritten
- Dominant language
- C#
- Stars
- 5.5k
- Forks
- 1.5k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 141
Description
### Issue Description
Discovered in https://github.com/dotnet/BenchmarkDotNet/issues/2664, passing `/p:IntermediateOutputPath=` with an absolute path causes the exe of a referenced project to be overwritten by the project referencing it.
### Steps to Reproduce
1. Create a C# console app project
```cs
Console.WriteLine("Hello World from ConsoleApp1");
```
2. Create a second C# console app project
```cs
Console.WriteLine("Hello World from ConsoleApp2");
```
3. Add a project reference to the second project from the first project
```xml
```
4. Build the project with dotnet sdk, passing absolute output paths.
```cmd
dotnet build -c Release /p:IntermediateOutputPath=C:\Users\Tim\source\repos\BuildPathBug\obj/
```
5. Run the produced `ConsoleApp2.exe` in the bin directory of ConsoleApp1.
Additional notes:
If I also include `/p:OutDir=` so that both projects output to the same bin directory, the `ConsoleApp2.exe` is correct if I do not include `/p:IntermediateOutputPath=`, and incorrect if I do include it.
Likewise, with both `/p:IntermediateOutputPath=` and `/p:OutDir=` included, the `ConsoleApp2.exe` is correct if I do not include the project reference in step 3, and incorrect if it is included.
### Expected Behavior
Console prints `Hello World from ConsoleApp2`.
### Actual Behavior
Console prints `Hello World from ConsoleApp1`.
### Analysis
_No response_
### Versions & Configurations
msbuild -version
```cmd
Microsoft (R) Build Engine version 16.6.0 for Mono
Copyright (C) Microsoft Corporation. All rights reserved.
16.6.0.22901
```
dotnet --version
```cmd
9.0.101
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.