我在Visual Studio中创建了一个.Net核心C#控制台应用程序,并使用以下步骤在Linux上对其进行了测试。
....\bin\Release\netcoreapp2.1\publish
中创建可执行文件。chmod 777 myApp.dll
./myApp.dll
但是,执行应用程序会显示
错误-bash:./myApp.dll:无法执行二进制文件
答案 0 :(得分:5)
好像您做了Framework-Dependendent Deployment。本质上,发布命令是:
Function caesarCipher(word As String) As String
'create an array of letters in their position for the cipher (a is 1st, b is 2nd)
Dim arrCipher As Variant
arrCipher = Split("a b c d e f g h i j k l m n o p q r s t u v x y z", " ")
'Create a dictionary from the array with the key being the letter and the item being index + 1
Dim dictCipher As Scripting.Dictionary
Set dictCipher = New Dictionary
For i = 0 To UBound(arrCipher)
dictCipher.Add arrCipher(i), i + 1
Next
'Now loop through the word letter by letter
For i = 1 To Len(word)
'and build the cipher output
caesarCipher = caesarCipher & IIf(Len(caesarCipher) = 0, "", " ") & dictCipher(LCase(Mid(word, i, 1)))
Next
End Function
FDD假定您将具有.NET Core运行时,以便在目标平台上运行应用程序。
将您通过<%@ ServiceHost Language="C#" Debug="true" Service="[Namespace.ClassName],[DllName]" Factory="Castle.Facilities.WcfIntegration.DefaultServiceHostFactory, Castle.Facilities.WcfIntegration" %>
目录复制到另一台计算机(可能是Linux,macOS或Windows)之后,您的应用程序仍需要.NET Core运行时才能运行您的应用程序。
安装.NET Core运行时取决于您使用的特定Linux发行版。安装完成后,您可以通过以下方式运行应用程序:
dotnet publish -c Release
Self-Contained Deployment是框架依赖部署的替代方法。在这种模式下,已发布的应用程序将包含您的应用程序以及.NET Core运行时的副本。在命令行上,执行SCD发布看起来像这样:
publish
有关在Visual Studio中执行此操作的信息,请参见上面的链接。然后,您应该看到一个包含dotnet /path/to/publish/myApp.dll
文件的dotnet publish -r linux-x64 -c Release
目录。您可以将该发布目录复制到Linux发行版中,然后运行:
bin\Release\netcoreapp2.1\linux-x64\publish\