"Go". NET core based on. Csproj Configuration File Publishing Project

Source: Internet
Author: User
Tags dotnet gettext

First, preface

. NET Toolchain in the latest Preview3 release, the new MSBuild project system was introduced, and the project files were returned to the . csproj XML file to manage, project files, package references, assembly references,. NET Core toolset, publish content definitions, and more. This article will mainly discuss how to publish the executable file in the new project system (. csproj). We all know that in previous releases, project files were managed by Project.json files to manage project and package references, then by removing dependencies---Microsoft.NETCore.App- > "type": "Platform" child node, and define the runtimes node to publish the executable file.

The executable is the file on the target machine that you do not need to install the . NET Core SDK or any runtime. For example, you can generate Coreapp.exe executable files on Windows, and in Linux you can use./coreapp to execute.

The principle of such an executable, is to use a C + + application as a carrier (host), load CoreCLR, through the CoreCLR and then load any assembly, interested friends here can also go to GitHub to see CoreCLR Part of the Clrhost.

Second, generate executable

In the new . csproj project file , we want to publish an executable file by manually creating a node named <RuntimeIdentifiers>, under which the node is added runtimeidentifiers that is, the previous rid definition, the RID is a unified naming label that describes the system platform. For example, the target system platform for the executable file I want to publish is defined as Win10 and Mac os 10.11.* as follows:

<PropertyGroup>      <RuntimeIdentifiers>win10-x64;osx.10.11-x64</RuntimeIdentifiers> </ Propertygroup>

Publish the target executables for each platform using the following command:

dotnet build-r win10-x64dotnet build-r osx.10.11-x64

The above command generates a debug version with symbol files and debug information, and your application will be generated in the .\bin\debug\netcoreapp1.0\< runtime_identifier> directory. If you want to build the final version of your production environment, get it by using the following command:

dotnet publish-c release-r win10-x64dotnet publish-c release-r osx.10.11-x64

Release version target execution files generated by the above command will be generated in the .\bin\release\netcoreapp1.0\<runtime_identifier> directory, and each target platform directory has generated executables, published project assemblies,. NET core dependencies, or necessary files and so on to ensure that the generator can be executed independently.

Let's look at a complete definition of a new csproj file:

<project toolsversion= "15.0" xmlns= "http://schemas.microsoft.com/developer/msbuild/2003" > <import Project = "$ (msbuildextensionspath) \$ (msbuildtoolsversion) \microsoft.common.props"/> <PropertyGroup> < Outputtype>exe</outputtype> <TargetFramework>netcoreapp1.0</TargetFramework> < Versionprefix>1.0.0</versionprefix> <DebugType>Portable</DebugType> <runtimeidentifiers >win10-x64;osx.10.11-x64</RuntimeIdentifiers> </PropertyGroup> <ItemGroup> <compile Include= "**\*.cs"/> <embeddedresource include= "**\*.resx"/> </ItemGroup> <ItemGroup> <pa     Ckagereference include= "Microsoft.NETCore.App" > <Version>1.0.1</Version> </PackageReference> <packagereference include= "Newtonsoft.json" > <Version>9.0.1</Version> </packagereference&    Gt <packagereference include= "MICROSOFT.NET.SDK" > <verSion>1.0.0-alpha-20161102-2</version> <PrivateAssets>All</PrivateAssets> </ packagereference> </ItemGroup> <import project= "$ (MSBuildToolsPath) \microsoft.csharp.targets"/> </Project>
Third, RID

RIDs are abbreviations for runtime identifier, which are used to define target operating system markings. The RID is constantly updated and we can find the RID definition in the COREFX project, and the commonly used RIDs are as follows:

  Windows RIDs

    • Windows 7/windows Server R2
      • win7-x64
      • win7-x86
    • Windows 8/windows Server 2012
      • win8-x64
      • win8-x86
      • win8-arm
    • Windows 8.1/windows Server R2
      • win81-x64
      • win81-x86
      • win81-arm
    • Windows 10/windows Server 2016
      • win10-x64
      • win10-x86
      • win10-arm
      • win10-arm64

Linux RIDs

  • Red Hat Enterprise Linux
    • rhel.7.0-x64
    • rhel.7.1-x64
    • rhel.7.2-x64
  • Ubuntu
    • ubuntu.14.04-x64
    • ubuntu.14.10-x64
    • ubuntu.15.04-x64
    • ubuntu.15.10-x64
    • ubuntu.16.04-x64
    • ubuntu.16.10-x64
  • Centos
    • centos.7-x64
  • Debian
    • debian.8-x64
  • Fedora
    • fedora.23-x64
    • fedora.24-x64
  • OpenSUSE
    • opensuse.13.2-x64
    • opensuse.42.1-x64
  • Oracle Linux
    • ol.7-x64
    • ol.7.0-x64
    • ol.7.1-x64
    • ol.7.2-x64
  • Currently supported Ubuntu derivatives
    • linuxmint.17-x64
    • linuxmint.17.1-x64
    • linuxmint.17.2-x64
    • linuxmint.17.3-x64
    • linuxmint.18-x64

OS X RIDs

    • osx.10.10-x64
    • osx.10.11-x64
    • osx.10.12-x64
Iv. System Dependence

Publish the target platform executable file, also need to rely on the system characteristics, next we see what the system needs components:

Windows Ubuntu Centos

OS X

  • Visual C + + Redistributable
  • For Visual Studio 2015
  • Libunwind8
  • Libunwind8-dev
  • GetText
  • Libicu-dev
  • Liblttng-ust-dev
  • Libcurl4-openssl-dev
  • Libssl-dev
  • Uuid-dev
  • Unzip
  • deltarpm
  • Epel-release
  • Unzip
  • Libunwind
  • GetText
  • Libcurl-devel
  • Openssl-devel
  • Zlib
  • Libicu-devel

  • Libssl Version 1.0.1



Original link: Http://www.cnblogs.com/maxzhang1985/p/6136886.html#_labelTop

"Go". NET core based on. Csproj Configuration File Publishing Project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.