2

I have developed a C# console application that is working properly from inside the Visual Studio environment. When I choose "Build Solution" under "Release" (but also under "Debug") a .DLL is generated, not an .EXE. I'm able to generate the .EXE using command line ("c:\Windows\Microsoft.NET\Framework64\v3.5\csc.exe" followed by the path to the .cs file), but it should be possible to generate the .EXE from inside the Visual Studio environment.

I have configured Visual Studio to use "C:\c#projs" as my projects location (menu path "Tools"->"Options"->"Projects and Solutions"->"Projects Location" instead of the default path under c:\Users\\Documents....

Here is the project file "App01.csproj"

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

  <PropertyGroup>
    <OutputPath>bin\</OutputPath>
    <OutputType>Exe</OutputType>
    <RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <StartupObject>App01.SetDirDatesProgram</StartupObject>
    <Platforms>AnyCPU;x64</Platforms>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <OutputPath>bin\</OutputPath>
    <RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
    <PlatformTarget>x64</PlatformTarget>
    <WarningLevel>0</WarningLevel>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <OutputPath>bin\</OutputPath>
    <RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
    <PlatformTarget>x64</PlatformTarget>
    <WarningLevel>0</WarningLevel>
  </PropertyGroup>

</Project>

And here is the generated "App01.deps.json" file:

"runtimeTarget": {
    "name": ".NETCoreApp,Version=v2.1",
    "signature": "da39a3ee5e6b4b0d3255bfef95601890afd80709"
  },
  "compilationOptions": {},
  "targets": {
    ".NETCoreApp,Version=v2.1": {
      "App01/1.0.0": {
        "runtime": {
          "App01.dll": {}
        }
      }
    }
  },
  "libraries": {
    "App01/1.0.0": {
      "type": "project",
      "serviceable": false,
      "sha512": ""
    }
  }
}

The "App01.deps.json" file was created by Visual Studio and contains (under the "runtime" key) "App01.dll" instead of "App01.exe".

My question is: What do I need to modify in Visual Studio in order to get (under the "runtime" key) "App01.exe" instead of "App01.dll" and obviously in order for App01.exe to be generated by Visual Studio so that I can deploy App01.exe elsewhere?

nvoigt
  • 75,013
  • 26
  • 93
  • 142
migol
  • 21
  • 1
  • 2
  • Possible duplicate of [VS2017 Compile NetCoreApp as EXE](https://stackoverflow.com/questions/44038847/vs2017-compile-netcoreapp-as-exe) – nvoigt Jan 14 '19 at 17:32

1 Answers1

0

Right-click the project name in Solution Explorer, choose Properties... Then go to the Application section and look for Output type: Be sure that it's set to Console Application.

For .NET Core console applications, I think you'll find the information you seek at this SO question: Build .NET Core console application to output an EXE?

Jazimov
  • 12,626
  • 9
  • 52
  • 59
  • Thanks Jazimov for this answer. I have done what you mentioned and I have confirmed that the output type is (and was) all along set to "Console Application". Thus the problem persists. The problem must be something else. – migol Jan 14 '19 at 15:42
  • I now see you're using .NET Core. Please see my edited answer. – Jazimov Jan 14 '19 at 16:01