简体   繁体   中英

Deploying C# Program as a Command Line Utility

I wrote a pretty simple program in C# to automatically generate csv files of a specific format from data from other spreadsheets, and I'd like to deploy it as a command line interface utility, ie a .exe file that can be run outside of VS Code, the IDE I'm using. I have the dotnet sdk tools installed, and I tried using dotnet msbuild with the .csproj file below:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <Configuration>Release</Configuration>
    <RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

</Project>

The command dotnet msbuild in the terminal built into VS Code generates a folder in bin called release that contains a .dll file, but not a .exe file. What parameters can I add to dotnet msbuild to generate a .exe file, or do I have to use another tool?

EDIT: I checked Build .NET Core console application to output an EXE?

and tried dotnet publish -c Release -r win10-x64 and got this error: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

SOLUTION: msbuild was the wrong tool to use-- I believe csc is the correct tool, as it created an application file.

msbuild是错误的工具 - 我相信csc是正确的工具,因为它创建了一个应用程序文件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM