使用dotnet命令发布跨平台项目对应平台的程序包
通过命令创建跨平台项目对应平台的程序包:分别生成win-x64、linux-x64、osx-x64平台的程序包
win-x64:
在项目文件中新增配置:
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
执行命令:
dotnet restore -p:RuntimeIdentifier=win-x64
dotnet msbuild -t:Publish -p:RuntimeIdentifier=win-x64 -p:Configuration=Release
linux-x64:
在项目文件中新增配置:
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
执行命令:
dotnet restore -p:RuntimeIdentifier=linux-x64
dotnet msbuild -t:Publish -p:RuntimeIdentifier=linux-x64 -p:Configuration=Release
osx-x64:
在项目文件中新增配置:
<RuntimeIdentifier>osx-x64</RuntimeIdentifier>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'osx-x64'"> <CFBundleName>CefNetDemo</CFBundleName> <CFBundleDisplayName>CefNetDemo</CFBundleDisplayName> <CFBundleIdentifier>gw.com.cn</CFBundleIdentifier> <CFBundleVersion>1.0.0</CFBundleVersion> <CFBundlePackageType>APPL</CFBundlePackageType> <CFBundleExecutable>CefNetDemo</CFBundleExecutable> <CFBundleIconFile>CefNetDemo.icns</CFBundleIconFile> <CFBundleShortVersionString>1.0.0.0</CFBundleShortVersionString> <NSPrincipalClass>CefNetDemo</NSPrincipalClass> <NSHighResolutionCapable>true</NSHighResolutionCapable> </PropertyGroup>
<PackageReference Condition="'$(RuntimeIdentifier)' == 'osx-x64'" Include="Dotnet.Bundle" Version="*" />
执行命令:
dotnet restore -p:RuntimeIdentifier=osx-x64
dotnet msbuild -t:BundleApp -p:RuntimeIdentifier=osx-x64 -p:Configuration=Release