Multi-targeting: Error CS2012 sometimes when AppendTargetFrameworkToOutputPath is set to false
- Dominant language
- C#
- Stars
- 5.5k
- Forks
- 1.5k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 133
Description
I am using Visual Studio 15.8.5 and I have a multi-target project setup that sets the output path based on the target and build configuration (like `output_dir\\`). Since I want the target as the parent folder I need to set `AppendTargetFrameworkToOutputPath` to false. However this setting also causes the target framework part not to be appended to the `obj` folder resulting in CS2012 sometimes due to race condition.
### Steps to reproduce
Here is a sample project file to reproduce this issue:
```XML
net40;netstandard2.0
false
..\..\Builds\net40\R_U_Debug\
..\..\Builds\netstandard2.0\R_U_Debug\
..\..\Builds\net40\R_U_Release\
..\..\Builds\netstandard2.0\R_U_Release\
```
### Actual behavior
Here is the error I get sometimes when I try to build:
> Error CS2012 Cannot open 'D:\Work\MyProject\obj\R_U_Debug\MyProject.dll' for writing -- 'The process cannot access the file 'D:\Work\MyProject\obj\R_U_Debug\MyProject.dll' because it is being used by another process.'
### Expected behavior
I tried setting a separate obj folder using the `BaseIntermediateOuputPath` property but this didn't take effect.
```XML
obj\net40
obj\netstandard2.0
```
Perhaps the `AppendTargetFrameworkToOutputPath` property should not be apply to the intermediate obj folders.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the sample multi-target project and inspect how AppendTargetFrameworkToOutputPath and BaseIntermediateOutputPath are applied to the output and obj paths. Reproduce a parallel build with net40 and netstandard2.0; done means each target has an independent intermediate path and the intermittent CS2012 error no longer occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100