-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to run published console app? #77
Comments
dotnet run path/to/helloworld.dll Your published project looks like a portable application which does not have a native bootstrapper like a shell script or a executable. |
You can also run dotnet . A portable app can run on any os and depends on the shared framework for the target platform being there. Currently, the way to get an executable app is to standalone and specify the target runtime ID in project.json. Remove, type: Platform from the netcore.app package reference and add a runtimes section with the right values such as win7-x64. |
Oh wow that worked. Thanks Peter! Managed to spit out the executable by using this
Managed to dig out abit about project.json here.
Any idea how to do that against the previously compiled helloworld.dll using the command line? I'm still curious about this one. Also, since the .NET Core is cross-platform, can I run that helloworld.dll compiled on Windows on EDIT Slightly off-topic but after reading around I tried playing around and used this configuration:
Then I do
No error but it asks me to install a framework. How to do this? |
You mean convert a previously compiled portable app into a standalone one? I don't think that's possible, at least not with the current version of the tooling |
Nonono, I meant running the .dll itself. I can't seem to run the compiled binary with |
I see, that should work.. if the app is compiled as portable it should run anywhere dotnet is installed. (shouldn't net a null reference error anyway) i'd file a bug on the cli repo Regarding you edit, did you mean to run on the rc3 bits? |
Regarding the edit, yes I meant to run on RC3 bits. Just pure curiosity. Do you know how to do it? |
ok :)
or you can just add it in the vs options Here is a sample project.json for a console app:
|
To run a published dll- |
Oh wow. That's unexpected. Maybe someone ought to make that clearer in the docs. Thanks! |
@ryanelian, agree - it would be good if it was mentioned right in 'dotnet --help'. I spend a bit of time this morning Bing'ing how to get my console app running on OSX from the publish folder |
@ryanelian and @jkristia, I've created the following issue on the core-docs repo to improve discoverability of this information: |
can someone point me to where i can get a list of all the options for runtimes? I'm trying to publish an executable for mac os but i'm not sure what i should be putting as a value in the |
@svick - thanks! based on that article - i've created a json file that looks like this. However when i run |
@mattcdavis1 Based on this article, you also need to remove the |
yep - that worked. thanks! |
First off, I'd like to say thank you to you guys for all this information. It really helped me out. Secondly, however, after reading this, I felt really sad in the pit of my stomach that this is so convoluted. This seems like a real mess. It feels like we've went backwards somehow. |
It's not very clean. We're looking at moving to a model where you always develop portable apps but you can choose to deploy standalone at publish time. |
This did not work for centos linux just for windows mac |
I am not sure if it's appropriate for me to add to this thread, but with the obsoletion of |
I tried it with the following snippet:
It does publish succesfully: |
You can also specify them with a single RuntimeIdentifier element:
As @davidfowl mentioned, we're looking into some alternate models that don't require changing your project in order to publish a standalone app or for a specific runtime. |
@albertromkes - were you able to actually generate the proper build for debian? According to this other bug, there is an issue generating builds for specific platforms: dotnet/sdk#527 |
@albertromkes I ran in similar issue, check your project.json and ensure, that followings is similar like this:
|
@Sebosek - I think that the situation that @albertromkes was describing is using the new tooling in csproj xml files since project.json is becoming obsolete |
@albertromkes , Is the only thing blocking you now the arm32 support so you can run the published output on RPi3? That will be coming soon. |
@Petermarcu Yes. I'm watching the releases closely :) |
There is a zip of Ubuntu arm32 binaries linked here: https://github.com/dotnet/core-setup/issues/725#issuecomment-268705518 You could try running on that :) |
I ran into this as well and wrote a small msbuild target for this. Basically, after the Publish target (which will publish the assets targeting the shared framework), invoke msbuild for each of the RuntimeIdentifiers specified. <Project ToolsVersion="15.0">
<Target Name="PublishAll" AfterTargets="Publish"
Condition="'$(RuntimeIdentifier)'=='' and '$(RuntimeIdentifiers)'!=''">
<ItemGroup>
<RIDsToPublish Include="$(RuntimeIdentifiers)" />
</ItemGroup>
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="Publish"
Properties="RuntimeIdentifier=%(RIDsToPublish.Identity)"
RemoveProperties="RuntimeIdentifiers"/>
</Target>
<Target Name="PublishRID" AfterTargets="Publish"
Condition="'$(RuntimeIdentifier)'!=''">
<Message Importance="High" Text="Published $(RuntimeIdentifier)" />
</Target>
</Project> You can import this target into your .csproj and then |
I thought they were adding that to the VS 2017 MSBuild story. Maybe not? |
That would be awesome! :) |
@srivatsn can you confirm? |
A publishallrids target? No I'm not tracking that for 1.0 |
re: |
OK OK. But using dotnet run app.dll I can use --server.urls http://localhost:12345 How can I use another port than default 5000 in case of "dotnet run" ? |
Hey all, My csproj looks like this: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
<RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>
</PropertyGroup>
</Project> However, when I use build or publish, I still only get a dll, pdb, and other random output files. What am I missing for creating a standalone exe? |
@jaxspades It should be: |
Still getting just a dll with that change. |
ditto. no exe output for me, either. |
To get an exe you have to specify that you want to build for a specific runtime:
This will output the exe in The docs on this are available here: https://docs.microsoft.com/en-us/dotnet/articles/core/deploying/index#self-contained-deployments-scd |
There is a bug in the 1.0/1.1 tooling where the path it shows at the end of publish didn't point to the location of the published app. Curious if that's what people are hitting. You have to look in |
Hi, I went through the Publish SCD routine in the doc that @jonstodle provided, which leads to this page: [https://docs.microsoft.com/en-us/dotnet/core/deploying/deploy-with-vs] I hope this helps - too bad I'll never get that hour back but... |
Let's say I have a hello world application named helloworld.
I ran
dotnet restore
thendotnet publish
. This appears:In the folder I have:
Looks compiled to me but doesn't seem to be an
exe
file.How to run this? Or is there a special compilation flag that outputs executable?
Thanks in advance!
The text was updated successfully, but these errors were encountered: