This sample demonstrates how to use .NET Framework and Docker together.
The sample builds the application in a container based on the larger .NET Framework SDK Docker image.
This sample requires the Docker Desktop for Windows.
You can quickly run a container with a pre-built .NET Framework Docker image.
Type the following Docker command:
docker run --rm mcr.microsoft.com/dotnet/framework/samples
The easiest way to get the sample is by cloning the samples repository with git, using the following instructions.
git clone https://github.com/microsoft/dotnet-framework-docker/
You can also download the repository as a zip.
You can build and run the sample in Docker using the following commands. The instructions assume that you are in the root of the repository.
cd samples
cd dotnetapp
docker build --pull -t dotnetapp .
docker run --rm dotnetapp
You can build this .NET Framework 4.8 application locally with the .NET SDK using the following instructions. The instructions assume that you are in the root of the repository.
You must have the .NET Framework 4.8 targeting pack installed. It is easiest to install with Visual Studio and the the Visual Studio Installer.
cd samples
cd dotnetapp
dotnet run
You can produce an application that is ready to deploy to production using the following command:
dotnet publish -c Release -o out
You can run the published application using the following command.
out\dotnetapp.exe
Note: The -c Release
argument builds the application in release mode (the default is debug mode). See the dotnet publish reference for more information on commandline parameters.
You can build this .NET Framework 4.8 application locally with MSBuild using the following instructions. The instructions assume that you are in the root of the repository and using the Developer Command Prompt for VS 2019
.
You must have the .NET Framework 4.8 targeting pack installed. It is easiest to install with Visual Studio and the the Visual Studio Installer.
cd samples
cd dotnetapp
msbuild /t:restore
msbuild /p:Configuration=Release
dotnetapp\bin\Release\net48\dotnetapp.exe
Note: The /p:Configuration=Release
argument builds the application in release mode (the default is debug mode). See the MSBuild Command-Line reference for more information on commandline parameters.
More Samples
Docs and More Information:
- .NET Docs
- ASP.NET Docs
- dotnet/core for starting with .NET on GitHub.
- dotnet/announcements for .NET announcements.
.NET Framework:
- dotnet/framework/sdk: .NET Framework SDK
- dotnet/framework/aspnet: ASP.NET Web Forms and MVC
- dotnet/framework/runtime: .NET Framework Runtime
- dotnet/framework/wcf: Windows Communication Foundation (WCF)
- dotnet/framework/samples: .NET Framework, ASP.NET and WCF Samples
.NET:
- dotnet: .NET
- dotnet/samples: .NET Samples