Hosting multiple instances of an app published with PublishSingleFile and IncludeNativeLibrariesForSelfExtract does not work as expected.
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Description
When compiling a web project to a single file application with `IncludeNativeLibrariesForSelfExtract` you can only run one instance of the application in IIS. If you try to run a second instance, it will try to extract from the same directory and fail to do so. This is contrary to the documented behavior I've read in one of [dotnet's design documents](https://github.com/dotnet/designs/blob/main/accepted/2020/single-file/extract.md). Specifically the linked document says,
> Check if the [extraction directory](Extraction Location) exists for this app:
If not, perform a new extraction:
Extract appropriate files to a temporary location // . This ensures that concurrent launches of the app do not interfere with each other.
This isn't the case in my experience.
If you remove the IncludeNativeLibrariesForSelfExtract option this problem goes away.
```
net5.0
false
OutOfProcess
true
true
win-x64
true
true
```
### Reproduction Steps
0. Open Visual Studio Version 16.10.3
1. File -> New -> Project -> ASP NET Core Web App -> Next -> .Net 5.0 -> Create
2. Paste this into the project file.
```
net5.0
false
OutOfProcess
true
true
win-x64
true
true
```
3. Folder publish
4. Copy to c:\inetpub\wwwroot\testproject1
5. Copy to c:\inetpub\wwwroot\testproject2
6. Convert each of these to web application in their own application pool
7. Attempt to view each of these applications
8. One will succeed and one will show a hosting error.
9. Remove `true` from the project file.
10. Republish to respective directories
11. Both applications work
### Expected behavior
The expected behavior is for both instances of the application to work properly when ` true` is in the project file prior to publishing.
### Actual behavior
The actual behavior is only a single instance working properly when ` true` is included in the project file prior to publishing.
### Regression?
I do not know if this worked in prior releases as this was my first attempt.
### Known Workarounds
Removing `true` from the project file prior to publishing enables both applications to work but does NOT produce a single file build output.
Renaming one of the .exe files and it's key in the associated web.config file allows this to work.
### Configuration
Visual Studio:
Microsoft Visual Studio Professional 2019
Version 16.10.3
OS:
Edition Windows 10 Pro
Version 21H1
Installed on 5/20/2021
OS build 19043.1237
Experience Windows Feature Experience Pack 120.2212.3530.0
### Other information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.