"No executable found matching command" .net core console application - .net-core

After publishing my .net core 2.0 console application...
dotnet publish src\myapp.console --output C:\publish\console --configuration Release
I try executing in this in the published folder
dotnet myapp.console
but I get the error
No executable found matching command "dotnet-myapp.console"

The trick is to include the full file name with .dll
ie:
dotnet myapp.console.dll

Related

Can I publish asp.net core with sdk and runtime files?

I am working to publish my project to vps server Linux
Can i publish project from visual studio with sdk and runtime files
without install sdks and runtime to my server ?
when you publish you can chose to include all the packages needed by the project by making it "self contained" here is the command line to build it:
dotnet publish -o c:\temp\yourproject --self-contained -r linux-x64

dotnet publish command not working with asp dotnet project in aws buildspecs.yml file

I have created sample dot net application, folder structure as follows.
When i am using this command
dotnet publish -c release -o ./build_output demorepo2.csproj build output is getting created inside build_output folder correctly.
Now i have another asp.net mvc web application.
Now i am using same command dotnet publish -c release -o ./build_output test1.csproj but this not working. Getting the following error.
Any idea why this error?
From ASP.NET Web Deployment using Visual Studio: Command Line Deployment
Try to run this command:
msbuild demorepo2.csproj /p:DeployOnBuild=true /p:PublishProfile=MyPublishProfile

DocFx Error after installing dotnet core 2.1.300

I've create a simple console application along with a simple docfx project. When I run the DocFX command to generate the documentation I get the following metadata warning and becuasue the warning leads to the documentation not being generated.
[18-06-05 05:52:41.715]Warning:MetadataCommand.ExtractMetadataWorkspace failed with: [Failure] Msbuild failed when processing the file 'E:\Files\tmp\docx\docfx_project\src\src.csproj' with message: C:\Program Files\dotnet\sdk\2.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets: (198, 5): Error loading lock file 'E:\Files\tmp\docx\docfx_project\src\obj\project.assets.json' : Object reference not set to an instance of an object.
later in the output you see
[18-06-05 05:52:42.467]Warning:[MetadataCommand.ExtractMetadata]No metadata is generated for src.
Anyone else run into this problem? How can I get metadata to generate?
To recreate the project is pretty simple:
goto dotnet cli tools command line
docfx init
cd src
dotnet new console
cd ..
docfx
I have installed and using the dotnet sdk 2.1.300
With .net 2.1 there is a breaking change in the use of tools, which are now installed and used globally like this:
dotnet watch
dotnet user-secrets
dotnet sql-cache
dotnet dev-certs
The developers of docfx are currently working on a version which supports .net 2.1 (docfx v3): https://github.com/dotnet/docfx/pull/2829
Here you can see the current status of implemenation: https://github.com/dotnet/docfx/projects/1
So the answer to your question is: as of yet you can't use docfx with .net 2.1

runtime folder with dotnet core application

If I create a net core 2 console app and get it to reference another project e.g. MyLibrary.csproj
This (MyLibrary.csproj) is a net core class library
If I run dotnet publish -c release --output test1
then in the output folder their is a runtime folder present
I have not found anywhere that describes this folders purpose.
Any one have a link?
Also do I need to copy this as part of my deployment?
The example I have has a reference to System.Data.SqlClient.dll which is present in the root publish folder(test1) so why does it need to get it from the runtime folder when I try to run via dotnet my.dll?
From the docs (https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish?tabs=netcore2x)
dotnet publish - Packs the application and its dependencies into a folder for deployment to a hosting system.

Publishing a dotnet application that's already running

I'm attempting to create a script to simplify the process of publishing a .NET Core website. I'm running into an issue when I run dotnet publish against an already running server. The server is IIS with the dotnet bundle installed, so IIS uses its app pool to start dotnet.
Here's my batch file. I'm happy to use another script type:
cd src/app
dotnet build --no-incremental
dotnet publish --framework netcoreapp1.0 --configuration Release --output ../../dist
When I run the script I get this error:
"The process cannot access the file 'C:\inetpub\wwwroot\app\dist\app.dll' because it is being used by another process."
This makes sense, it appears I need to stop, deploy, and restart dotnet. Can I do this from the script? Or is my approach to this problem wrong?
The best way is to drop an app_offline.htm file to your application folder. This will make IIS stop your application and serve the contents of the app_offline.htm file to the user while you are copying the new version. Once you complete copying the new version of your application remove the app_offline.htm file and IIS will start your application.
You can find more details on running ASP.NET Core applications with IIS in my post.
Based on Pawel's answer, I have a deploy folder containing my app_offline.html file and multiple deploy scripts to IIS. Here's a sample script I use to deploy:
copy .\app_offline.htm C:\hosting\my-project\app_offline.htm
dotnet publish ../MyProject.csproj -r win-x64 -f netcoreapp2.1 --self-contained -c Release -o C:\hosting\my-project
del C:\hosting\my-project\app_offline.htm
I think this is a valid solution, but doesn't help when I want to script the build process.
Stop-Website "xxx"
Stop-WebAppPool "xxx"
Start-Sleep -Seconds 5
dotnet publish --output d:\publocation
Stop-WebAppPool "xxx"
Start-Website "xxx"
if you've created a published profile in Visual Studio and you're using IIS, then you can use that profile instead of writing directly to the destination directory:
dotnet publish /p:PublishProfile=Properties\PublishProfiles\IISProfile.pubxml

Resources