none
Visual Studio 2017 : Not generating an .EXE file when building a solution RRS feed

  • Question

  • I am new to Visual Studio but have a large experience with several programming languages.

    I have configured Visual Studio 2017 (Community) to use  the directory c:\c#projs for my C# projects, instead of a directory inside the c:\users directory.

    I have created a console application project and I can debug and test it without problems. As the application is doing what I want, I want to pickup the generated EXE file in order to deploy it elsewhere. The problem is that Visual Studio is generating a DLL but not an EXE.

    I have searched a lot on the NET and tried many things but I get no EXE from Visual Studio. However I was able to produce an EXE using command line. Calling c:\Windows\Microsoft.NET\Framework64\v3.5\csc.exe  followed by the path to my .CS application generates the EXE that I need. But this solution is not satisfactory as it should be possible for such a sophisticated product as Visual Studio to generate the EXE directly from inside Visual Studio itself (when I choose "build solution"or "publish") without being necessary to resort to command line.

    Here is the contents of my App01.csproj file :

    <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>

    I hope somebody is able to direct me in the right direction. The C# and Visual Studio docs are of high quality but they are very large and it would take me a lot of time to discover the solution to this problem I have read bits and pieces here and there, but without success.

    Thanks in advance.

    Saturday, January 12, 2019 2:09 PM

All replies

  • Perhaps the Community edition is slightly different than the other versions, but here are the properties I have for a Console app (not using the Community edition of VS2017):

    Does yours look similar? Note that I do not see "Exe" as one of the options for "Output Type".

    Here is the xml:

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
      <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
        <ProjectGuid>{AAAB4A8C-4CCD-4EB4-A659-0F25BA3E70CB}</ProjectGuid>
        <OutputType>Exe</OutputType>
        <AppDesignerFolder>Properties</AppDesignerFolder>
        <RootNamespace>ConsoleApplication1</RootNamespace>
        <AssemblyName>ConsoleApplication1</AssemblyName>
        <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
        <FileAlignment>512</FileAlignment>
        <TargetFrameworkProfile />
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <PlatformTarget>AnyCPU</PlatformTarget>
        <DebugSymbols>true</DebugSymbols>
        <DebugType>full</DebugType>
        <Optimize>false</Optimize>
        <OutputPath>bin\Debug\</OutputPath>
        <DefineConstants>DEBUG;TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
        <Prefer32Bit>false</Prefer32Bit>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
        <PlatformTarget>AnyCPU</PlatformTarget>
        <DebugType>pdbonly</DebugType>
        <Optimize>true</Optimize>
        <OutputPath>bin\Release\</OutputPath>
        <DefineConstants>TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
        <Prefer32Bit>false</Prefer32Bit>
      </PropertyGroup>
      <ItemGroup>
        <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
          <SpecificVersion>False</SpecificVersion>
          <HintPath>..\..\Newtonsoft.Json.dll</HintPath>
        </Reference>
        <Reference Include="System" />
        <Reference Include="System.Configuration" />
        <Reference Include="System.Core" />
        <Reference Include="System.Net.Http" />
        <Reference Include="System.ServiceProcess" />
        <Reference Include="System.Xml.Linq" />
        <Reference Include="System.Data.DataSetExtensions" />
        <Reference Include="Microsoft.CSharp" />
        <Reference Include="System.Data" />
        <Reference Include="System.Xml" />
      </ItemGroup>
      <ItemGroup>
        <Compile Include="Class1.cs" />
        <Compile Include="Program.cs" />
        <Compile Include="Properties\AssemblyInfo.cs" />
        <Compile Include="TestStuff.cs" />
      </ItemGroup>
      <ItemGroup>
        <None Include="App.config">
          <SubType>Designer</SubType>
        </None>
      </ItemGroup>
      <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
      <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
           Other similar extension points exist, see Microsoft.Common.targets.
      <Target Name="BeforeBuild">
      </Target>
      <Target Name="AfterBuild">
      </Target>
      -->
    </Project>


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Saturday, January 12, 2019 5:49 PM
    Moderator
  • Hi melocotone,

    According to your description and related configuration code, it seems that it is a .net core 2.1 console application, if you want to generate exe file, please run the following publish command.

    dotnet publish -c Release -r win10-x64

    For more information, please refer to:

    https://stackoverflow.com/questions/44074121/build-net-core-console-application-to-output-an-exe

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, January 14, 2019 6:34 AM
    Moderator
  • Hi melocotone,

    Any update? Do you try the method that I mentioned. 

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, February 4, 2019 7:16 AM
    Moderator