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

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

Related

Jenkins Dotnet Project Publishing Issue

I am trying to publish my dotnet project-api from jenkins via powershell. The problem is when I publish it from powershell it's missing around 30 files and I can't reach api. However when I publish it from visual studio manually (or from visual studio package manager console with commands) it works perfectly. What might be causing this issue?
Here are the commands that I am running to publish api ;
dotnet restore
dotnet build --configuration release
dotnet publish -c release --output "path to the publish file"
I have also tried with this to publish command yet it didn'T work;
dotnet publish dotnet publish -c Release --self-contained -r win10-x64
I have been trying to figure this issue for a long time but I couldn't find a way. I would highly appreciate any help. Thanks!!
You should try following 2 Execute Windows batch command
Command
"C:\Program Files\dotnet\dotnet.exe" restore yourProjectSLN file
[E.g:yourProjectSLN = git/FolderName/ProjectName.sln , it should be same as jenkins configuration]
Command
dotnet publish yourProject_csproj_file_location -c:Release
[E.g:yourProject_csproj_file_location = git\FolderName\ProjectName.csproj]

dotnet publish command is not creating zip file for C# library

In visual studio solution I have single .net core 2.0 library project. And to the publish the library i am using dotnet publish -c release command
however its not zipping the publish folder. I have read the issue 6598 and use the suggested approach using dotnet build command as below
dotnet build ApiRouting.sln /nologo /p:PublishProfile=Release /p:PackageLocation="C:\temp\Routing\package" /p:OutDir="C:\temp\Routing\out" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /maxcpucount:1 /p:platform="Any CPU" /p:configuration="Release" /p:DesktopBuildPackageLocation="C:\temp\Routing\package\package.zip"
`
but that did not work either.
My project is aws lambda project which is C# library project not asp.net web project so i tried removing /p:WebPublishMethod=Package option but that did not work either.
Questions
1>What parameters i need to pass to publish command so that it would create zip file of publish folder.
2>In linked issue 6598 why its suggested to use build command instead of publish when build command only builds the project?
(on side note i can use aws tools for visual studio and use Publish to AWS Lambda and it creates zip file and deploys it to AWS directly from visual studio. However, we are using Jenkins for CI so i want use dotnet cli to create zip file so jenkins can execute that command and create zip file.)
i found it. These 2 links helped me
https://docs.aws.amazon.com/lambda/latest/dg/lambda-dotnet-how-to-create-deployment-package.html
https://docs.aws.amazon.com/lambda/latest/dg/lambda-dotnet-coreclr-deployment-package.html
first installed Amazon.Lambda.Tools
dotnet tool install -g Amazon.Lambda.Tools
and then to package and deploy
dotnet lambda deploy-function apirouting –-function-role myrole --profile lambdadep --profile-location C:\test\testawsprofile

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

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

Deploy ASP.NET Core without runtime and packages?

I'm doing build & deploy content in Visual Studio but this takes a lot of space (170 MB) because it contains runtime (dnx core clr) and all packages files.
Can I deploy web app to windows server and automatically install runtime and all packages on server for my web app?
You can scripted it to download the runtime as you instal it.
#powershell -NoProfile -ExecutionPolicy unrestricted -Command "&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}"
Dependencies can be then be dowloaded using the dnu restore command based on you project.json file.

Msbuild packaging Issue

Currently I am working on a mvc3 project and I use msbuild command line tool to do the packaging.
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>msbuild MVC-Client.csproj /t:package /P:Configuration=staging
In my machine this command executes successfully and it creates a deploy-able package.And in deploy bat file it has following web deployment configs.
MSDeployPath="C:\Program Files (x86)\IIS\**Microsoft Web Deploy V2**\"
And but when I am trying to run same msbuild command in my build server machine(jenkings server) it creates a different bat file with following web deployment configs.
set MSDeployPath="C:\Program Files (x86)\IIS\Microsoft Web Deploy\"
In both machines I use same version of msbuild. And also i have both msdeply1 and msdeploy2 installed in those machines. What could be the reason for this ? I am using Microsoft (R) Build Engine Version 4.0.30319.1 version of msbuild.
Thanks
It's seems that install web deploy v1 after Web deploy v2, try to reinstall Web Deploy v2 on your build server.

Resources