### Launch the server process Source: https://github.com/dotnet/samples/blob/main/orleans/Presence/README.md Start the PresenceService application. ```dotnetcli dotnet run --project ./src/PresenceService ``` -------------------------------- ### Run the sample projects Source: https://github.com/dotnet/samples/blob/main/orleans/Blazor/BlazorWasm/README.md Commands to start the server and client components of the Blazor WebAssembly sample. ```dotnetcli dotnet run --project BlazorWasm.Server ``` ```dotnetcli dotnet run --project BlazorWasm.Client ``` -------------------------------- ### Install .NET Core 3.1 SDK on Ubuntu Source: https://github.com/dotnet/samples/blob/main/core/tutorials/buggyamb/Docs/linux_installation_instructions.md Commands to update package lists and install the .NET Core 3.1 SDK. ```bash sudo apt-get update; sudo apt-get install -y apt-transport-https && sudo apt-get update && sudo apt-get install -y **dotnet-sdk-3.1** ``` -------------------------------- ### Run BuggyAmb application Source: https://github.com/dotnet/samples/blob/main/core/tutorials/buggyamb/Docs/linux_installation_instructions.md Command to start the application from the installation directory. ```bash dotnet BuggyAmb.dll ``` -------------------------------- ### Verify .NET Core installation Source: https://github.com/dotnet/samples/blob/main/core/tutorials/buggyamb/Docs/windows_installation_instructions.md Use this command in a command prompt to list all installed .NET Core SDKs and runtimes. ```dotnetcli dotnet --info ``` -------------------------------- ### Install Required NuGet Packages Source: https://github.com/dotnet/samples/blob/main/iot/dotnet-iot-and-nanoframework/dotnet-iot/Readme.md Install these packages to enable IoT device bindings, GPIO access, and Azure IoT Hub communication. ```bash dotnet add package Iot.Device.Bindings dotnet add package System.Device.Gpio dotnet add package Microsoft.Azure.Devices.Client ``` -------------------------------- ### Client Output Example Source: https://github.com/dotnet/samples/blob/main/core/extensions/OutOfProcCOM/README.md Expected output when running the native or managed client. ```text π = 3.140616091322624 ``` -------------------------------- ### Run the Orleans Sample Application Source: https://github.com/dotnet/samples/blob/main/orleans/VBHelloWorld/README.md Execute the host project from the command line to start the Orleans sample. ```dotnetcli dotnet run --project HelloWorld ``` -------------------------------- ### Launch the load generator Source: https://github.com/dotnet/samples/blob/main/orleans/Presence/README.md Start the application that simulates game server heartbeats. ```dotnetcli dotnet run --project ./src/LoadGenerator ``` -------------------------------- ### Nginx Installation and Verification Source: https://github.com/dotnet/samples/blob/main/core/tutorials/buggyamb/Docs/linux_installation_instructions.md Commands to install Nginx and verify its configuration and status. ```bash sudo apt-get install nginx ``` ```bash sudo nginx -t ``` ```bash sudo systemctl status nginx ``` ```bash sudo systemctl start nginx ``` ```bash sudo service nginx start ``` -------------------------------- ### Example console output Source: https://github.com/dotnet/samples/blob/main/orleans/BankAccount/README.md Sample output showing successful transfers and transaction aborts. ```console We transferred 100 credits from Pasqualino to Ida. Pasqualino balance: 1500 Ida balance: 1600 ``` ```console Error transferring 100 credits from Derick to Xaawo: Transaction 2edc92f5-a94d-4167-9522-fa661cc030ff Aborted because of an unhandled exception in a grain method call. See InnerException for details. InnerException: Withdrawing 100 credits from account "Derick" would overdraw it. This account has 0 credits. ``` -------------------------------- ### Running the service project Source: https://github.com/dotnet/samples/blob/main/orleans/GPSTracker/README.md Commands to launch the service host, including an example of passing an instance identifier. ```dotnetcli dotnet run --project GPSTracker.Service ``` ```dotnetcli dotnet run --project GPSTracker.Service -- --InstanceId 1 ``` -------------------------------- ### Install specific .NET SDK version Source: https://github.com/dotnet/samples/blob/main/core/mono-samples/Android/README.md Use the dotnet-install script to install the required .NET 6.0.100-alpha.1.20628.2 SDK version. ```bash ./dotnet-install.sh --version 6.0.100-alpha.1.20628.2 ``` -------------------------------- ### Run BankServer and BankClient Source: https://github.com/dotnet/samples/blob/main/orleans/BankAccount/README.md Commands to start the server and client processes from the command line. ```bash dotnet run --project BankServer ``` ```bash dotnet run --project BankClient ``` -------------------------------- ### Run the ASP.NET Core application Source: https://github.com/dotnet/samples/blob/main/azure/app-insights-aspnet-core-quickstart/README.md Starts the application to begin telemetry ingestion. ```dotnetcli dotnet run ``` -------------------------------- ### Launch the player watcher Source: https://github.com/dotnet/samples/blob/main/orleans/Presence/README.md Start the client application that observes player status. ```dotnetcli dotnet run --project ./src/PlayerWatcher ``` -------------------------------- ### Sample MSBuild Project File Source: https://github.com/dotnet/samples/blob/main/msbuild/Test.README.md An example MSBuild project file used to trigger a custom task during integration tests. ```xml netstandard2.1 MySettingSuccess example ``` -------------------------------- ### Running the device gateway Source: https://github.com/dotnet/samples/blob/main/orleans/GPSTracker/README.md Command to start the simulation of GPS devices. ```dotnetcli dotnet run --project GPSTracker.FakeDeviceGateway ``` -------------------------------- ### Run the Adventure Client Source: https://github.com/dotnet/samples/blob/main/orleans/Adventure/README.md Execute this command in a separate terminal to start the client and begin playing the game. ```bash dotnet run --project AdventureClient ``` -------------------------------- ### Run the Adventure Server Source: https://github.com/dotnet/samples/blob/main/orleans/Adventure/README.md Execute this command in the terminal to start the Orleans server component of the game. ```bash dotnet run --project AdventureServer ``` -------------------------------- ### Run the TicTacToe game server with an instance ID Source: https://github.com/dotnet/samples/blob/main/orleans/TicTacToe/README.md Starts the game server with a specific instance ID to allow clustering in a local environment. ```bash dotnet run -- --InstanceId 1 ``` -------------------------------- ### Running observability containers Source: https://github.com/dotnet/samples/blob/main/orleans/GPSTracker/README.md Docker commands to start Prometheus, Jaeger, and Zipkin for monitoring and tracing. ```docker docker run -p 9090:9090 -v ..\dotnet\samples\GPSTracker\prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus ``` ```docker docker run -d --name jaeger -e COLLECTOR_ZIPKIN_HOST_PORT=:9411 -p 5775:5775/udp -p 6831:6831/udp -p 6832:6832/udp -p 5778:5778 -p 16686:16686 -p 14268:14268 -p 14250:14250 -p 9411:9411 jaegertracing/all-in-one:1.22 ``` ```docker docker run -p 9411:9411 openzipkin/zipkin ``` -------------------------------- ### Run the Orleans Chat Room Server Source: https://github.com/dotnet/samples/blob/main/orleans/ChatRoom/README.md Execute this command in a terminal to start the chat room server. ```PowerShell dotnet run --project .\ChatRoom.Service\ ``` -------------------------------- ### Consume Generated REST API Client in C# Source: https://github.com/dotnet/samples/blob/main/msbuild/rest-api-client-generation/README.md Example of initializing and using the generated PetShopRestClient. Note that HttpClientFactory is recommended for production environments instead of direct HttpClient instantiation. ```csharp using System; using System.Net.Http; namespace PetReaderExecTaskExample { internal class Program { private const string baseUrl = "https://petstore.swagger.io/v2"; static void Main(string[] args) { HttpClient httpClient = new HttpClient(); httpClient.BaseAddress = new Uri(baseUrl); var petClient = new PetShopRestClient.PetShopRestClient(httpClient); var pet = petClient.GetPetByIdAsync(1).Result; Console.WriteLine($"Id: {pet.Id} Name: {pet.Name} Status: {pet.Status} CategoryName: {pet.Category.Name}"); } } } ``` -------------------------------- ### Run the Orleans Chat Room Client Source: https://github.com/dotnet/samples/blob/main/orleans/ChatRoom/README.md Execute this command in one or more terminal windows to start the chat client after the server is running. ```PowerShell dotnet run --project .\ChatRoom.Client\ ``` -------------------------------- ### Build and Run LINQ Samples Source: https://github.com/dotnet/samples/blob/main/core/linq/csharp/README.md Commands to restore dependencies and execute the sample application within a subdirectory. ```bash dotnet restore dotnet run ``` -------------------------------- ### Build Sample Project Source: https://github.com/dotnet/samples/blob/main/README.md Execute this command in the sample folder to verify the project compiles without errors. ```console dotnet build ``` -------------------------------- ### Run the sample Source: https://github.com/dotnet/samples/blob/main/orleans/TransportLayerSecurity/README.md Commands to execute the sample on different operating systems. ```powershell .\run.cmd ``` ```bash ./run.sh ``` -------------------------------- ### Define a Guid property class Source: https://github.com/dotnet/samples/blob/main/msbuild/custom-task-code-generation/AppSettingStronglyTyped/AppSettingStronglyTyped.Test/Resources/guid-prop-class.txt Use this structure to store a constant Guid value within a static class member. ```csharp using System; namespace MyNamespace { public class MyguidPropSetting { public readonly static Guid Id = Guid.Parse("79a107f3-0109-4425-aa16-81918663b4ed"); } } ``` -------------------------------- ### Build and Run Sample Source: https://github.com/dotnet/samples/blob/main/azure/sdk-identity-resources-storage/README.md Commands to compile and execute the .NET console application. ```dotnetcli dotnet build dotnet run ``` -------------------------------- ### Create and run a new WPF application Source: https://github.com/dotnet/samples/blob/main/wpf/README.md Use the dotnet CLI to scaffold a new WPF project and execute it from the command line. ```cmd dotnet new wpf -o MyWPFApp cd MyWPFApp dotnet run ``` -------------------------------- ### Navigate to directory Source: https://github.com/dotnet/samples/blob/main/framework/libraries/README.md Command to enter the project directory. ```bash cd frameworks-library ``` -------------------------------- ### Install Application Insights SDK Source: https://github.com/dotnet/samples/blob/main/azure/app-insights-aspnet-core-quickstart/README.md Adds the Microsoft.ApplicationInsights.AspNetCore NuGet package to the project. ```dotnetcli dotnet add package Microsoft.ApplicationInsights.AspNetCore --version 2.17.0 ``` -------------------------------- ### Build and run the MetadataLoadContext sample Source: https://github.com/dotnet/samples/blob/main/core/assembly/MetadataLoadContext/readme.md Use these commands in the sample directory to compile and execute the application with a target assembly path. ```dotnetcli dotnet build dotnet run -- ``` -------------------------------- ### Initialize root CA directory structure Source: https://github.com/dotnet/samples/blob/main/iot/dotnet-iot-and-nanoframework/create-certificate.md Creates the necessary folders and files for the certification authority, including the database, serial number, and private key storage. ```bash mkdir rootca cd rootca mkdir certs db private touch db/index openssl rand -hex 16 > db/serial echo 1001 > db/crlnumber ``` -------------------------------- ### Build and package library Source: https://github.com/dotnet/samples/blob/main/framework/libraries/README.md Commands to compile the source and create a NuGet package. ```bash cd src/Library dotnet build dotnet pack ``` -------------------------------- ### Get Subscription Details Source: https://github.com/dotnet/samples/blob/main/azure/sdk-identity-resources-storage/README.md Retrieves Azure subscription information required for environment configuration. ```azurecli az account show ``` -------------------------------- ### Build and Run Library Source: https://github.com/dotnet/samples/blob/main/core/getting-started/golden/README.md Commands to restore dependencies and build the library project. ```bash dotnet restore dotnet build ``` -------------------------------- ### Prepare Raspberry Pi Deployment Directory Source: https://github.com/dotnet/samples/blob/main/iot/dotnet-iot-and-nanoframework/dotnet-iot/Readme.md Creates and sets permissions for the deployment directory on the remote device. ```bash mkdir DNSensorAzureIoTHub sudo chmod 775 ./DNSensorAzureIoTHub ``` -------------------------------- ### Systemd Service Management Commands Source: https://github.com/dotnet/samples/blob/main/core/tutorials/buggyamb/Docs/linux_installation_instructions.md Commands to create, reload, enable, start, and check the status of the BuggyAmb service. ```bash sudo vi /etc/systemd/system/buggyamb.service ``` ```bash sudo systemctl daemon-reload ``` ```bash sudo systemctl enable buggyamb ``` ```bash sudo systemctl start buggyamb ``` ```bash sudo systemctl status buggyamb ``` ```bash sudo journalctl -fu buggyamb.service ``` -------------------------------- ### Initialize Build Engine Mock Source: https://github.com/dotnet/samples/blob/main/msbuild/Test.README.md Sets up a Moq mock for IBuildEngine to capture build errors during test initialization. ```csharp private Mock buildEngine; private List errors; [TestInitialize()] public void Startup() { buildEngine = new Mock(); errors = new List(); buildEngine.Setup(x => x.LogErrorEvent(It.IsAny())).Callback(e => errors.Add(e)); } ``` -------------------------------- ### Apply format string to a date Source: https://github.com/dotnet/samples/blob/main/windowsforms/formatting-utility/cs/readme.md Example of using a composite format string with Console.WriteLine to format a date object. ```cs Console.WriteLine("{0:YYYY-MM-dd}", thisDate); ``` -------------------------------- ### Initial Project File Structure Source: https://github.com/dotnet/samples/blob/main/msbuild/custom-task-code-generation/README.md The basic structure of a .NET Standard 2.0 project file before adding NuGet packaging metadata. ```xml netstandard2.0 ``` -------------------------------- ### Configure Custom Task in MSBuild Project Source: https://github.com/dotnet/samples/blob/main/msbuild/custom-task-code-generation/README.md Example of using UsingTask to reference a local assembly and defining targets to generate code during the build process. ```xml Exe net6.0 $(MSBuildProjectDirectory) MySetting MSBuildConsoleExample mysettings ``` -------------------------------- ### Create a native AOT console project Source: https://github.com/dotnet/samples/blob/main/core/nativeaot/HelloWorld/README.md Initializes a new .NET console project with native AOT support enabled. ```bash > dotnet new console -o HelloWorld --aot > cd HelloWorld ``` -------------------------------- ### Build and Run VisioDemo via MSBuild Source: https://github.com/dotnet/samples/blob/main/core/extensions/VisioDemo/README.md Commands to restore, build, and execute the VisioDemo project from the command line. ```cmd msbuild -t:Restore;Build VisioDemo.csproj bin\Debug\netcoreapp3.1\VisioDemo.exe ``` -------------------------------- ### Publish and Deploy via Batch Script Source: https://github.com/dotnet/samples/blob/main/iot/dotnet-iot-and-nanoframework/dotnet-iot/Readme.md Automates publishing and transferring files to the IoT device using pscp. ```bash dotnet publish -r linux-arm /p:ShowLinkerSizeComparison=true pushd .\bin\Debug\net5.0\linux-arm\publish pscp -pw 1234 -v -r .\* pi@192.168.1.147:DNSensorAzureIoTHub popd ``` -------------------------------- ### Run NativeApp binary Source: https://github.com/dotnet/samples/blob/main/core/interop/cpp-cli/README.md Command to execute the native application after building the solution. ```shell bin\Debug\x64\NativeApp.exe ``` -------------------------------- ### Manual Publish and Deploy Commands Source: https://github.com/dotnet/samples/blob/main/iot/dotnet-iot-and-nanoframework/dotnet-iot/Readme.md Commands for manually publishing the project and deploying via scp, followed by execution on the device. ```bash dotnet publish -r linux-arm cd .\bin\Debug\net5.0\linux-arm\ scp publish\* pi@192.168.1.109:BlinkTutorial ``` ```bash cd DNSensorAzureIoTHub ./DNSensorAzureIoTHub ``` -------------------------------- ### Build and run ExcelDemo via MSBuild Source: https://github.com/dotnet/samples/blob/main/core/extensions/ExcelDemo/ReadMe.md Commands to restore dependencies, build the project, and execute the resulting binary from the command line. ```cmd msbuild -t:Restore;Build ExcelDemo.csproj bin\Debug\netcoreapp3.1\ExcelDemo.exe ``` -------------------------------- ### Sample systemd unit file Source: https://github.com/dotnet/samples/blob/main/core/tutorials/buggyamb/Docs/linux_installation_instructions.md Configuration file for managing the BuggyAmb process as a systemd service. ```ini [Unit] Description=BuggyAmb ASP.NET Core 3.1 [Service] WorkingDirectory=/var/buggyamb/buggyamb_v1.1 ExecStart= /usr/bin/dotnet /var/buggyamb/buggyamb_v1.1/BuggyAmb.dll Restart=always ``` -------------------------------- ### Build and test the project Source: https://github.com/dotnet/samples/blob/main/core/console-apps/NewTypesMsBuild/README.md Compiles and executes unit tests from the test/NewTypesTests directory. ```console dotnet build dotnet test ``` -------------------------------- ### Define settings file content Source: https://github.com/dotnet/samples/blob/main/msbuild/custom-task-code-generation/README.md Create a configuration file with the specified extension to be processed by the custom task. ```text Greeting:string:Hello World! ``` -------------------------------- ### Run Unit Tests Source: https://github.com/dotnet/samples/blob/main/core/getting-started/golden/README.md Commands to restore, build, and execute unit tests for the library. ```bash dotnet restore dotnet build dotnet test ``` -------------------------------- ### Build shared library with NativeAOT Source: https://github.com/dotnet/samples/blob/main/core/nativeaot/NativeLibrary/README.md Command to publish the .NET project as a native shared library. ```bash > dotnet publish --use-current-runtime ``` -------------------------------- ### Define Program Entry Point Source: https://github.com/dotnet/samples/blob/main/README.md Structure the Program class with a Main method to invoke specific sample logic. ```csharp public class Program { public void Main(string[] args) { WhereClause1.QuerySyntaxExample(); // Add the method syntax as an example. WhereClause1.MethodSyntaxExample(); } } ``` -------------------------------- ### Execute Build and Collect Output Source: https://github.com/dotnet/samples/blob/main/msbuild/Test.README.md Runs the configured build process and captures the standard output stream. ```csharp //Act ExecuteCommandAndCollectResults(); ``` ```csharp private void ExecuteCommandAndCollectResults() { buildProcess.Start(); while (!buildProcess.StandardOutput.EndOfStream) { output.Add(buildProcess.StandardOutput.ReadLine() ?? string.Empty); } buildProcess.WaitForExit(); } ``` -------------------------------- ### Initialize MSBuild Process for Testing Source: https://github.com/dotnet/samples/blob/main/msbuild/Test.README.md Configures the process environment for running MSBuild, including setting the path to the dotnet executable and redirecting standard output. ```csharp public const string MSBUILD = "C:\\Program Files\\dotnet\\dotnet.exe"; private Process buildProcess; private List output; [TestInitialize()] public void Startup() { output = new List(); buildProcess = new Process(); buildProcess.StartInfo.FileName = MSBUILD; buildProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; buildProcess.StartInfo.CreateNoWindow = true; buildProcess.StartInfo.RedirectStandardOutput = true; } ``` -------------------------------- ### Build and run in Docker Source: https://github.com/dotnet/samples/blob/main/core/nativeaot/HelloWorld/README.md Commands to build and execute the application within a Linux or Windows container environment. ```bash docker build -t hello . & docker run -t hello ``` ```bash docker build -t hello -f Dockerfile.windowsservercore-x64 . & docker run -t hello ``` -------------------------------- ### Configure IoT Hub Credentials Source: https://github.com/dotnet/samples/blob/main/iot/dotnet-iot-and-nanoframework/nanoFramework/Readme.md Define the device ID and IoT Hub address in Program.cs to establish the connection. ```csharp const string DeviceID = ""; const string IotBrokerAddress = ".azure-devices.net"; ``` -------------------------------- ### Run unit tests Source: https://github.com/dotnet/samples/blob/main/framework/libraries/README.md Command to execute unit tests for the library. ```bash cd ../../test/LibraryTests dotnet test ``` -------------------------------- ### Add Packaging Project Build Targets Source: https://github.com/dotnet/samples/blob/main/windowsforms/MSIX-WindowsForms/README.md Include these targets in your wapproj file to handle entry point fixing and trigger the publish target for referenced projects. ```xml @(PackageOutputGroups);__GetPublishItems CoreWinFormsApp1\CoreWinFormsApp1.exe ``` -------------------------------- ### Run ManagedApp binary Source: https://github.com/dotnet/samples/blob/main/core/interop/cpp-cli/README.md Command to execute the managed application after building the solution. ```shell bin\Debug\x64\ManagedApp.exe ``` -------------------------------- ### Configure SampleProfiler CMake build Source: https://github.com/dotnet/samples/blob/main/core/profiling/stacksampling/CMakeLists.txt Sets up the library build environment, including conditional source inclusion for Windows and library target definition. ```cmake set(CMAKE_INCLUDE_CURRENT_DIR ON) if (WIN32) set(BASE_SOURCES ${BASE_SOURCES} src/SampleProfiler.def) endif(WIN32) set(SOURCES ${BASE_SOURCES} src/SampleProfiler.cpp src/dllmain.cpp src/sampler.cpp) add_library(SampleProfiler SHARED ${SOURCES}) ``` -------------------------------- ### Arrange Task Parameters Source: https://github.com/dotnet/samples/blob/main/msbuild/Test.README.md Configures the ITaskItem mock and initializes the custom task with required parameters and the build engine. ```csharp //Arrange var item = new Mock(); item.Setup(x => x.GetMetadata("Identity")).Returns($".\\Resources\\complete-prop.setting"); var appSettingStronglyTyped = new AppSettingStronglyTyped { SettingClassName = "MyCompletePropSetting", SettingNamespaceName = "MyNamespace", SettingFiles = new[] { item.Object } }; appSettingStronglyTyped.BuildEngine = buildEngine.Object; ``` -------------------------------- ### Expected Sample Output Source: https://github.com/dotnet/samples/blob/main/core/interop/IDynamicInterfaceCastable/README.md The console output displays the representation of native objects and the results of method calls performed through the dynamic interface implementation. ```text Native Object #0 - does not implement IGreet - does not implement ICompute Native Object #1 - implements IGreet -- Hello World from NativeObject #1 - does not implement ICompute Native Object #2 - does not implement IGreet - implements ICompute -- Returned sum: 5 Native Object #3 - implements IGreet -- Hello World from NativeObject #3 - implements ICompute -- Returned sum: 6 ``` -------------------------------- ### Create and run a Windows Forms app via CLI Source: https://github.com/dotnet/samples/blob/main/windowsforms/README.md Use these commands to scaffold a new Windows Forms project and execute it from the terminal. ```cmd dotnet new winforms -o MyWinFormsApp cd MyWinFormsApp dotnet run ``` -------------------------------- ### Import function from library Source: https://github.com/dotnet/samples/blob/main/core/nativeaot/NativeLibrary/README.md Retrieve the function pointer from the loaded library handle using the entry point name. ```c myFunc MyImport = symLoad(handle, funcName); ``` -------------------------------- ### Building a static library with dotnet publish Source: https://github.com/dotnet/samples/blob/main/core/nativeaot/NativeLibrary/README.md Use the NativeLib=Static property to generate a static library. Note that shared libraries are generally preferred over static libraries for compatibility reasons. ```bash > dotnet publish /p:NativeLib=Static --use-current-runtime ``` -------------------------------- ### Configure .NET Core Project for Packaging Source: https://github.com/dotnet/samples/blob/main/windowsforms/MSIX-WindowsForms/README.md Add this target to your .NET Core csproj file to ensure files are correctly identified for the publishing process. ```xml <_PublishItem Include="@(ResolvedFileToPublish->'%(FullPath)')" TargetPath="%(ResolvedFileToPublish.RelativePath)" OutputGroup="__GetPublishItems" /> <_PublishItem Include="$(ProjectDepsFilePath)" TargetPath="$(ProjectDepsFileName)" /> <_PublishItem Include="$(ProjectRuntimeConfigFilePath)" TargetPath="$(ProjectRuntimeConfigFileName)" /> ```