-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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. 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.
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishReadyToRun>true</PublishReadyToRun>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
</PropertyGroup>
Reproduction Steps
-
Open Visual Studio Version 16.10.3
-
File -> New -> Project -> ASP NET Core Web App -> Next -> .Net 5.0 -> Create
-
Paste this into the project file.
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishReadyToRun>true</PublishReadyToRun>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
</PropertyGroup>
- Folder publish
- Copy to c:\inetpub\wwwroot\testproject1
- Copy to c:\inetpub\wwwroot\testproject2
- Convert each of these to web application in their own application pool
- Attempt to view each of these applications
- One will succeed and one will show a hosting error.
- Remove
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>from the project file. - Republish to respective directories
- Both applications work
Expected behavior
The expected behavior is for both instances of the application to work properly when <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract> is in the project file prior to publishing.
Actual behavior
The actual behavior is only a single instance working properly when <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract> 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 <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract> 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
Metadata
Metadata
Assignees
Labels
Type
Projects
Status