This provides information how to prepare a Publish Profile and deploy an application to a development board.
-
Once you have an application setup in Visual Studio, right-click the project in the Solution Explorer and select Publish...
-
In the Pick a publish target dialog, select Folder, choose a folder to publish your application files and click Create Profile. The example below shows a path of C:\PublishedApps.
-
A default profile, FolderProfile.pubxml, will now be created and added to your project. You can view it in the Solution Explorer under your project > Properties > PublishProfiles folder.
-
It is a good practice to rename your profile to something you can relate with your project. In the Publish Window, click the Actions dropdown and select Rename Profile. A Rename Profile dialog prompts you to rename your profile. Click Save after renaming.
-
You can configure the profile's settings by clicking Configure... in the Publish Window. A Profile Settings dialog prompt includes a few options.
Notes
-
Currently, the Target Runtime doesn't offer a selection for Linux ARM or Windows ARM. You will need to manually open the profile's XML and change the RuntimeIdentifier element to linux-arm or win-arm shown below:
<RuntimeIdentifier>linux-arm</RuntimeIdentifier> or.. <RuntimeIdentifier>win-arm</RuntimeIdentifier> or both.. <RuntimeIdentifiers>linux-arm;win-arm</RuntimeIdentifiers>
-
Deployment Mode Options:
- Framework Dependent - App relies on the presence of a shared system-wide version of .NET Core on the target system. This will create a smaller size package.
- Self-contained - .NET Core and required libraries will be bundled with your application creating a larger size package. IoT devices are usually constrained by memory resources. There is a useful NuGet package available that helps trim unused files. Reference Microsoft.Packaging.Tools.Trimming for more information.
-
While there are more options available that can be modified, this only shows the basics. It is recommended to read more in the provided References section below.
-
-
You can view the contents by double-clicking the profile. The contents should look similar to the XML below after your modifications.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<TargetFramework>netcoreapp2.1</TargetFramework>
<PublishDir>C:\PublishedApps</PublishDir>
<RuntimeIdentifier>linux-arm</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<_IsPortable>false</_IsPortable>
</PropertyGroup>
</Project>
-
You can now publish your application by clicking Publish in the Publish Window. All folders/files should now be packaged in the specified publish folder.
-
Your application is now ready for deployment to the target device.
-
Once you have an application setup, navigate to the directory where the project is located and run the
dotnet publish
command. Below shows a few common options and example.-
-c defines the build configuration (Debug or Release).
-
-o specifies the output path where application will be packaged.
-
-r publishes the application for given runtime (e.g. linux-arm, win-arm, etc.) being targeted.
dotnet publish -c Release -o C:\DeviceApiTester -r linux-arm
-
-
Your application is now ready for deployment to the target device.
The application can be deployed to a target device once the Publish Profile and related files have been packaged. There are various tools for transferring files depending on the platform being used. Below are a few popular tools available.
- Have Your Pi and Eat It Too: .NET Core 2.1 on Raspberry Pi
- Visual Studio publish profiles for ASP.NET Core app deployment
- Deploy an app to a local folder using Visual Studio
- Deploy .NET Core apps with Visual Studio
- How to: Edit Deployment Settings in Publish Profile (.pubxml) Files and the .wpp.targets File in Visual Studio Web Projects
- .NET Core application deployment
- dotnet publish
- .NET Core RID Catalog