Dotnet 8 publishing Self-Contained Application not Working


Question: When I upgrade from Asp.Net 7 to Asp.Net 8, and then publishing the app as a Self-Contained, this does not work in Visual Studio.


Login to See the Rest of the Answer

Answer: This seems to be a bug in the new Asp.Net Core 8 and Visual Studio, as a work-around, you need to publish as a Naitive IOT or publish as a Framework-dependent and install Asp.Net Core 8 Runtime on the Server.


To publish an ASP.NET 8 application as a self-contained package that can run on a Linux Docker container, you will need to follow these steps:

1. Create a new project in Visual Studio using the "ASP.NET Core Web Application" template and select "Self-Contained App (.NET Core App)" as the target framework.
2. Install the necessary dependencies for your application by running the following command in the Package Manager Console:
```
dotnet restore
```
3. Build your application by running the following command in the Package Manager Console:
```
dotnet build
```
4. Create a Dockerfile in the root directory of your project with the following contents:
```
FROM mcr.microsoft.com/dotnet/core/sdk:8.1 AS build
WORKDIR /app
COPY . /app
RUN dotnet restore
RUN dotnet build
FROM mcr.microsoft.com/dotnet/core/sdk:8.1 AS run
WORKDIR /app
COPY --from=build /app/bin/Debug/* /app/
EXPOSE 80
CMD ["dotnet","MyApp.dll"]


Other
published
v.1.00




For peering opportunity Autonomouse System Number: AS401345 Custom Software Development at ErnesTech Email AddressContact: [email protected]