从VS 2017发布.net核心应用

时间:2017-04-12 12:29:48

标签: asp.net-core .net-core publish visual-studio-2017

我正在Visual Studio 2017社区版下创建一个新的解决方案,它主要是一个.net核心Web应用程序。

它完美无缺,完全没问题,但是我们想将它部署到Debian机器并且是自包含的,所以我们将运行时标识符添加到项目中。到目前为止,问题出现的时候我们想要为我们拥有的任何平台发布应用程序(到目录),没有选项来指定目标平台,创建的发布文件只是.net程序集,没有本机模块。

当然,如果我们使用dotnet publish -r (platform)它按预期工作,它会创建正确的平台文件,一切似乎都没问题,但是必须转到命令行来编译它是非常烦人的。

所以问题是,如何使用Visual Studio 2017发布具体平台的自包含应用程序?它甚至可能还是仍然缺少?

2 个答案:

答案 0 :(得分:1)

您可以更新项目文件csproj以添加runtimeIdentifier:

<RuntimeIdentifier>win7-x86</RuntimeIdentifier>

将win7-x86替换为您想要的运行时。

即使在发布屏幕中它显示Runtime:Portable,它似乎也会产生一个独立版本。

visual studio 2017 publish screen

探险家的结果:

explorer publish result

vs2017执行命令

 C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Roslyn\csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702,1705,2008 /nostdlib+ /platform:x86 /errorreport:prompt /warn:4 /define:TRACE;RELEASE;NETCOREAPP1_1 /errorendlocation /preferreduilang:en-US /reference:C:\Users\Joel\.nuget\packages\microsoft.csharp\4.3.0\ref\netstandard1.0\Microsoft.CSharp.dll /reference:C:\Users\Joel\.nuget\packages\microsoft.visualbasic\10.1.0\ref\netstandard1.1\Microsoft.VisualBasic.dll /reference:C:\Users\Joel\.nuget\packages\microsoft.win32.primitives\4.3.0\ref\netstandard1.3\Microsoft.Win32.Primitives.dll /reference:C:\Users\Joel\.nuget\packages\system.appcontext\4.3.0\ref\netstandard1.6\System.AppContext.dll /reference:C:\Users\Joel\.nuget\packages\system.buffers\4.3.0\lib\netstandard1.1\System.Buffers.dll /reference:C:\Users\Joel\.nuget\packages\system.collections.concurrent\4.3.0\ref\netstandard1.3\System.Collections.Concurrent.dll /reference:C:\Users\Joel\.nuget\packages\system.collections\4.3.0\ref\netstandard1.3\System.Collections.dll /reference:C:\Users\Joel\.nuget\packages\system.collections.immutable\1.3.0\lib\netstandard1.0\System.Collections.Immutable.dll /reference:C:\Users\Joel\.nuget\packages\system.componentmodel.annotations\4.3.0\ref\netstandard1.4\System.ComponentModel.Annotations.dll /reference:C:\Users\Joel\.nuget\packages\system.componentmodel\4.3.0\ref\netstandard1.0\System.ComponentModel.dll /reference:C:\Users\Joel\.nuget\packages\system.console\4.3.0\ref\netstandard1.3\System.Console.dll /reference:C:\Users\Joel\.nuget\packages\system.diagnostics.debug\4.3.0\ref\netstandard1.3\System.Diagnostics.Debug.dll /reference:C:\Users\Joel\.nuget\packages\system.diagnostics.diagnosticsource\4.3.0\lib\netstandard1.3\System.Diagnostics.DiagnosticSource.dll /reference:C:\Users\Joel\.nuget\packages\system.diagnostics.process\4.3.0\ref\netstandard1.4\System.Diagnostics.Process.dll /reference:C:\Users\Joel\.nuget\packages\system.diagnostics.tools\4.3.0\ref\netstandard1.0\System.Diagnostics.Tools.dll /reference:C:\Users\Joel\.nuget\packages\system.diagnostics.tracing\4.3.0\ref\netstandard1.5\System.Diagnostics.Tracing.dll /reference:C:\Users\Joel\.nuget\packages\system.dynamic.runtime\4.3.0\ref\netstandard1.3\System.Dynamic.Runtime.dll /reference:C:\Users\Joel\.nuget\packages\system.globalization.calendars\4.3.0\ref\netstandard1.3\System.Globalization.Calendars.dll /reference:C:\Users\Joel\.nuget\packages\system.globalization\4.3.0\ref\netstandard1.3\System.Globalization.dll /reference:C:\Users\Joel\.nuget\packages\system.globalization.extensions\4.3.0\ref\netstandard1.3\System.Globalization.Extensions.dll /reference:C:\Users\Joel\.nuget\packages\system.io.compression\4.3.0\ref\netstandard1.3\System.IO.Compression.dll /reference:C:\Users\Joel\.nuget\packages\system.io.compression.zipfile\4.3.0\ref\netstandard1.3\System.IO.Compression.ZipFile.dll /reference:C:\Users\Joel\.nuget\packages\system.io\4.3.0\ref\netstandard1.5\System.IO.dll /reference:C:\Users\Joel\.nuget\packages\system.io.filesystem\4.3.0\ref\netstandard1.3\System.IO.FileSystem.dll /reference:C:\Users\Joel\.nuget\packages\system.io.filesystem.primitives\4.3.0\ref\netstandard1.3\System.IO.FileSystem.Primitives.dll /reference:C:\Users\Joel\.nuget\packages\system.io.filesystem.watcher\4.3.0\ref\netstandard1.3\System.IO.FileSystem.Watcher.dll /reference:C:\Users\Joel\.nuget\packages\system.io.memorymappedfiles\4.3.0\ref\netstandard1.3\System.IO.MemoryMappedFiles.dll /reference:C:\Users\Joel\.nuget\packages\system.io.unmanagedmemorystream\4.3.0\ref\netstandard1.3\System.IO.UnmanagedMemoryStream.dll /reference:C:\Users\Joel\.nuget\packages\system.linq\4.3.0\ref\netstandard1.6\System.Linq.dll /reference:C:\Users\Joel\.nuget\packages\system.linq.expressions\4.3.0\ref\netstandard1.6\System.Linq.Expressions.dll /reference:C:\Users\Joel\.nuget\packages\system.linq.parallel\4.3.0\ref\netstandard1.1\System.Linq.Parallel.dll /reference:C:\Users\Joel\.nuget\packages\system.linq.queryable\4.3.0\ref\netstandard1.0\System.Linq.Queryable.dll /reference:C:\Users\Joel\.nuget\packages\system.net.http\4.3.0\ref\netstandard1.3\System.Net.Http.dll /reference:C:\Users\Joel\.nuget\packages\system.net.nameresolution\4.3.0\ref\netstandard1.3\System.Net.NameResolution.dll /reference:C:\Users\Joel\.nuget\packages\system.net.primitives\4.3.0\ref\netstandard1.3\System.Net.Primitives.dll /reference:C:\Users\Joel\.nuget\packages\system.net.requests\4.3.0\ref\netstandard1.3\System.Net.Requests.dll /reference:C:\Users\Joel\.nuget\packages\system.net.security\4.3.0\ref\netstandard1.3\System.Net.Security.dll /reference:C:\Users\Joel\.nuget\packages\system.net.sockets\4.3.0\ref\netstandard1.3\System.Net.Sockets.dll /reference:C:\Users\Joel\.nuget\packages\system.net.webheadercollection\4.3.0\ref\netstandard1.3\System.Net.WebHeaderCollection.dll /reference:C:\Users\Joel\.nuget\packages\system.numerics.vectors\4.3.0\ref\netstandard1.0\System.Numerics.Vectors.dll /reference:C:\Users\Joel\.nuget\packages\system.objectmodel\4.3.0\ref\netstandard1.3\System.ObjectModel.dll /reference:C:\Users\Joel\.nuget\packages\system.reflection.dispatchproxy\4.3.0\ref\netstandard1.3\System.Reflection.DispatchProxy.dll /reference:C:\Users\Joel\.nuget\packages\system.reflection\4.3.0\ref\netstandard1.5\System.Reflection.dll /reference:C:\Users\Joel\.nuget\packages\system.reflection.extensions\4.3.0\ref\netstandard1.0\System.Reflection.Extensions.dll /reference:C:\Users\Joel\.nuget\packages\system.reflection.metadata\1.4.1\lib\netstandard1.1\System.Reflection.Metadata.dll /reference:C:\Users\Joel\.nuget\packages\system.reflection.primitives\4.3.0\ref\netstandard1.0\System.Reflection.Primitives.dll /reference:C:\Users\Joel\.nuget\packages\system.reflection.typeextensions\4.3.0\ref\netstandard1.5\System.Reflection.TypeExtensions.dll /reference:C:\Users\Joel\.nuget\packages\system.resources.reader\4.3.0\lib\netstandard1.0\System.Resources.Reader.dll /reference:C:\Users\Joel\.nuget\packages\system.resources.resourcemanager\4.3.0\ref\netstandard1.0\System.Resources.ResourceManager.dll /reference:C:\Users\Joel\.nuget\packages\system.runtime\4.3.0\ref\netstandard1.5\System.Runtime.dll /reference:C:\Users\Joel\.nuget\packages\system.runtime.extensions\4.3.0\ref\netstandard1.5\System.Runtime.Extensions.dll /reference:C:\Users\Joel\.nuget\packages\system.runtime.handles\4.3.0\ref\netstandard1.3\System.Runtime.Handles.dll /reference:C:\Users\Joel\.nuget\packages\system.runtime.interopservices\4.3.0\ref\netcoreapp1.1\System.Runtime.InteropServices.dll /reference:C:\Users\Joel\.nuget\packages\system.runtime.interopservices.runtimeinformation\4.3.0\ref\netstandard1.1\System.Runtime.InteropServices.RuntimeInformation.dll /reference:C:\Users\Joel\.nuget\packages\system.runtime.numerics\4.3.0\ref\netstandard1.1\System.Runtime.Numerics.dll /reference:C:\Users\Joel\.nuget\packages\system.security.cryptography.algorithms\4.3.0\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll /reference:C:\Users\Joel\.nuget\packages\system.security.cryptography.encoding\4.3.0\ref\netstandard1.3\System.Security.Cryptography.Encoding.dll /reference:C:\Users\Joel\.nuget\packages\system.security.cryptography.primitives\4.3.0\ref\netstandard1.3\System.Security.Cryptography.Primitives.dll /reference:C:\Users\Joel\.nuget\packages\system.security.cryptography.x509certificates\4.3.0\ref\netstandard1.4\System.Security.Cryptography.X509Certificates.dll /reference:C:\Users\Joel\.nuget\packages\system.security.principal\4.3.0\ref\netstandard1.0\System.Security.Principal.dll /reference:C:\Users\Joel\.nuget\packages\system.text.encoding\4.3.0\ref\netstandard1.3\System.Text.Encoding.dll /reference:C:\Users\Joel\.nuget\packages\system.text.encoding.extensions\4.3.0\ref\netstandard1.3\System.Text.Encoding.Extensions.dll /reference:C:\Users\Joel\.nuget\packages\system.text.regularexpressions\4.3.0\ref\netcoreapp1.1\System.Text.RegularExpressions.dll /reference:C:\Users\Joel\.nuget\packages\system.threading\4.3.0\ref\netstandard1.3\System.Threading.dll /reference:C:\Users\Joel\.nuget\packages\system.threading.tasks.dataflow\4.7.0\lib\netstandard1.1\System.Threading.Tasks.Dataflow.dll /reference:C:\Users\Joel\.nuget\packages\system.threading.tasks\4.3.0\ref\netstandard1.3\System.Threading.Tasks.dll /reference:C:\Users\Joel\.nuget\packages\system.threading.tasks.extensions\4.3.0\lib\netstandard1.0\System.Threading.Tasks.Extensions.dll /reference:C:\Users\Joel\.nuget\packages\system.threading.tasks.parallel\4.3.0\ref\netstandard1.1\System.Threading.Tasks.Parallel.dll /reference:C:\Users\Joel\.nuget\packages\system.threading.thread\4.3.0\ref\netstandard1.3\System.Threading.Thread.dll /reference:C:\Users\Joel\.nuget\packages\system.threading.threadpool\4.3.0\ref\netstandard1.3\System.Threading.ThreadPool.dll /reference:C:\Users\Joel\.nuget\packages\system.threading.timer\4.3.0\ref\netstandard1.2\System.Threading.Timer.dll /reference:C:\Users\Joel\.nuget\packages\system.xml.readerwriter\4.3.0\ref\netstandard1.3\System.Xml.ReaderWriter.dll /reference:C:\Users\Joel\.nuget\packages\system.xml.xdocument\4.3.0\ref\netstandard1.3\System.Xml.XDocument.dll /debug- /debug:portable /filealign:512 /nologo /optimize+ /out:obj\Release\netcoreapp1.1\win7-x86\ConsoleApp1.dll /ruleset:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Team Tools\Static Analysis Tools\\Rule Sets\MinimumRecommendedRules.ruleset" /target:exe /warnaserror- /utf8output /deterministic+ /analyzer:C:\Users\Joel\.nuget\packages\microsoft.codeanalysis.analyzers\1.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll /analyzer:C:\Users\Joel\.nuget\packages\microsoft.codeanalysis.analyzers\1.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll Program.cs "C:\Users\Joel\AppData\Local\Temp\.NETCoreApp,Version=v1.1.AssemblyAttributes.cs" obj\Release\netcoreapp1.1\win7-x86\\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs obj\Release\netcoreapp1.1\win7-x86\\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs obj\Release\netcoreapp1.1\win7-x86\\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs obj\Release\netcoreapp1.1\win7-x86\ConsoleApp1.AssemblyInfo.cs

答案 1 :(得分:1)

目前VS2017不会执行此操作,因此您必须转到命令行并运行它。

dotnet publish -c release -r ubuntu.14.04-x64

显然用你的debian味道取代ubuntu。

这也是我的csproj文件中你可能也需要它。

<OutputType>Exe</OutputType>