Sdk: dotnet new / restore / publish do not generate EXE file

Created on 12 Jan 2017  路  14Comments  路  Source: dotnet/sdk

I would like to generate a standalone exe file when publishing the app.
The app needs to consume the latest post-1.1 bits (e.g. 1.2.0-beta-249##).
Despite the csproj file having Exe I always get a .dll instead of .exe

Steps to reproduce

install the latest tooling
create folder foo
dotnet new
dotnet restore
dotnet build
dotnet publish (or dotnet publish -r win7-x64)

Expected behavior

foo.exe file gets generated in the published folder

Actual behavior

foo.dll gets generated

Specifying -r runtime_id used to do the trick but not anymore.

Environment data

dotnet --info output:
.NET Command Line Tools (1.0.0-preview5-004478)

Product Information:
Version: 1.0.0-preview5-004478
Commit SHA-1 hash: 4d3e2872fe

Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\1.0.0-preview5-004478

All 14 comments

@KKhurin Try it with ...

<RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>

in the property group.<PropertyGroup>.

Also: https://docs.microsoft.com/en-us/dotnet/articles/core/preview3/deploying/#self-contained-deployments-scd.

With this, I'm going to close this issue. Please reopen if @GuardRex's suggestion or the document does not help you. Thanks!

If anyone stumbles on this wondering how to generate an exe, you must either:
A) target netcoreapp1.0
B) target netstandard1.x and include a <PackageReference> to Microsoft.NETCore.Runtime.CoreCLR

As of 1.0.0-rc3-004530 you don't appear to need any <RuntimeIdentifier> in the project file. You can just:

dotnet restore -r <RID>
dotnet publish -r <RID>

It still does not work.

DLL file is generated but no EXE

dotnet publish -r win7-x64

@damircolak You have a \ of Exe? Here's a sample from one of my test projects ... this one happens to be a 2.0 self-contained test app that I use for nightly bleeding edge testing ...

  <PropertyGroup>
    <AssemblyTitle>Self-contained Web Application</AssemblyTitle>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <RuntimeFrameworkVersion>2.0.0-*</RuntimeFrameworkVersion>
    <WarningsAsErrors>true</WarningsAsErrors>
    <AssemblyName>testselfcontained</AssemblyName>
    <OutputType>Exe</OutputType>
    <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
    <MvcRazorCompileOnPublish Condition=" '$(Configuration)' == 'Release' ">true</MvcRazorCompileOnPublish>
  </PropertyGroup>

There's guidance in https://docs.microsoft.com/en-us/dotnet/core/deploying/deploy-with-cli and https://docs.microsoft.com/en-us/dotnet/core/tutorials/using-with-xplat-cli

Yes, I have output type exe and of course I went through those links. It did not help.

I am trying to build win7-x64 exe file.

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


  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.1</TargetFramework>

    <RuntimeIdentifiers>
        <RuntimeIdentifiers>win10-x64;osx.10.11-x64;win7-x64;ubuntu.14.04-x64</RuntimeIdentifiers>
    </RuntimeIdentifiers>

  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
  </ItemGroup>
</Project>

You have the \ element twice there ... try this ...

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <RuntimeIdentifiers>win10-x64;osx.10.11-x64;win7-x64;ubuntu.14.04-x64</RuntimeIdentifiers>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
  </ItemGroup>
</Project>

~Also note that I think u were trying to publish with -r win7-x64, but you list win10-x64 in the runtimes in the project file. Match them and see if it works. Either publish with -r win10-x64 or change it in the project file to win7-x64.~ Ignore that ... I see u have both.

win7-64??? .... win7-x64 ... is it just due to a typo when you tried to execute the dotnet publish command?

Just a typo :-)

I had several different runtime identifiers. Building a self contained deployments for each of them.

win10-x64 worked, win7-x64 did not.

win10-x64 exe gives this error when you try to start it:

Error: assembly specified in the dependencies manifest was not found -- package: 'microsoft.codeanalysis.common', version: '1.3.0', path: 'lib/netstandard1.3/Microsoft.CodeAnalysis.dll'

Those RID's are definitely supported, so not sure unless you have packages conflicting with each other.

Just to set a baseline for yourself again, (if you don't already have it), get nuget.exe by downloading it from https://dist.nuget.org/win-x86-commandline/latest/nuget.exe, put somewhere and on your PATH (or just run it from wherever you download it), then execute ...

nuget locals all -clear

... to clean out the package caches.

Next, do a dotnet restore on your app. Then, see if your dotnet publish -r win<X>-x64 commands will give you some good outputs that will run.

Otherwise, the best thing to do is put your project up on GH in a repo so I (or someone) can pull it down and see if we can find out where it's going wrong.

Thanks, I'll give it a try.

@GuardRex fyi the locals command also works using the included dotnet nuget command. No need to download the nuget cli for that 馃槈

@dasMulli I was hoping that you were watching this discussion! lol ..... Old habits die hard! It's true, I haven't been using the new command for that (YET).

Was this page helpful?
0 / 5 - 0 ratings