I am trying to build a web deploy package on the .net core sdk docker image to be used to deploy to a windows server running iis (the deployment being done on a seperate windows vm). This is the command I am running (this can also be done via the publish UI in visual studio):
dotnet publish src/SpaceForce.sln -c release -o out -p:WebPublishMethod=Package;PackageAsSingleFile=True;DesktopBuildPackageLocation="../Package/SpaceForce.WebAPI.zip"
On Windows this produces a folder with the following files and then when i'm ready to deploy, i just run the cmd file:
SpaceForce.WebAPI.deploy.cmd
SpaceForce.WebAPI.deploy-readme.txt
SpaceForce.WebAPI.Parameters.xml
SpaceForce.WebAPI.SetParameters.xml
SpaceForce.WebAPI.SourceManifest.xml
SpaceForce.WebAPI.zip
but on Linux (.net core sdk docker image) it produces the following error:
/usr/share/dotnet/sdk/3.1.300/Sdks/Microsoft.NET.Sdk.Publish/targets/PublishTargets/Microsoft.NET.Sdk.Publish.MSDeployPackage.targets(97,5): error MSB6004: The specified task executable location "%ProgramW6432%/IIS/Microsoft Web Deploy V3/msdeploy.exe" is invalid. [/home/osboxes/src/spaceforce/src/SpaceForce.WebAPI/SpaceForce.WebAPI.csproj]
on this page, it has this note but i'm not sure if this applies in my case:
The dotnet msbuild command is a cross-platform command and can compile ASP.NET Core apps on macOS and Linux. However, MSBuild on macOS and Linux isn't capable of deploying an app to Azure or other MSDeploy endpoints.
If i can build on linux, i am happy to run the cmd file on a windows box for deployment. Is it possible to build this package on linux?
As you quoted, MSDeploy is a Windows-only thing. Using the WebPublishMethod switch tries to run "%ProgramW6432%/IIS/Microsoft Web Deploy V3/msdeploy.exe", which is obviously not present in the linux container.
To publish an app from a linux environment to an IIS server you have to publish the app without the WebDeploy specific features and then send the published files to the IIS server. On the server you configure an app with a set physical path and move the published files into that path.
To get the files from the docker image you have to create a temporary container and copy the files
# Dockerfile
RUN dotnet publish src/SpaceForce.sln -c Release -f netcoreapp3.1 -o /out
# bash script to get the publish dir from the image
imageId=$(docker create <IMAGE_NAME>)
docker cp $imageId:/out/ <HOST_DIR>
docker rm $imageId
This article should get you started.
Hope this helps a litte 🙂
Related
I want to deploy a Hello World Blazor Server App created with the Blazor App Source Template 3.1.11 in VS2019 C#
The app is created in VS2019 on Windows 10
The docs show how to create the /bin/Release/{TARGET FRAMEWORK}/publish folder
I copied the files here to the domain folder in my hosting package, but do not know the next step.
web.config is for windows hosting.
What do I need to do for Linux?
At the moment I get a 403 error if I go to the site.
I can publish the app to a windows hosted site.
[Update]
It turns out that the Linux server does not have DotNet installed.
By default, dotnet publish publishes the entire application for running on the current operating system. When that does not match where you intend to run the application you can specify the runtime to publish for with -r|--runtime.
Something like this should work: dotnet publish -r linux-x64
A 403 error would lie somewhere in the IIS/web server configuration. Look at the config file or the IIS settings.
I have made a simple application in net core 3.1 using mvc and razor pages and I want to deploy it in windows 10. I am working on Ubuntu 20.04 with Visual Studio Code. I have deployed the application as a Self-contained deployment (SCD) running
dotnet publish -c Release -r win10-x64 --self-contained True
Then, copy the folder to a Windows machine. If I double click the .exe, everything runs perfect. But when I create a windows service with
sc create RazService binPath= %~dp0Raz.exe
sc start RazService
sc config RazService start=auto
When running the app, it enters the home page. But when I navigate to another page that requires access to the database (SQLite), it cannot find it.
I tried to change the keys-values in the regedit to change the root directory but it didn't work.
So What am i missing here?
Thanks.
I have problem with publishing under IIS. i have been trying to automate publishing web app to the IIS by following cmd dotnet publish App.csproj -c -o C:\inetpub\wwwroot\App.Web -c release, but it just added it as folder, how to publish it as a Web Application, is it possible?
you will need to convert your folder to an application.
To do so, just right click on it, and select "convert to application"
After that, as you're publishing a .netCore application, you will have to configure the application pool running that app, and set "Framework version" to unmaged. (and leave
the pipeline to integrated)
more information on hosting .NetCore on IIS
This is a one step configuration.
All you next publish should work fine.
Some more explanations :
.NetCore is platform agnostics, so it can't know you're deploying on IIS.
When you deploy with legacy .net (4.xx) Visual studio has an IIS target for deployment, and did all the work.
With .net core, as it can also be run under linux, mac, etc.. the IIS specificities have been removed.
I wrote a console app in C# on VS 2017 for mac, and the resulting build file is a .dll. I can run that fine in the IDE and from the terminal with "dotnet blah.dll".
What I really want is to give my little console app to my Windows friends who can then run it.
I'm not finding detail on the web or here on how to tell VS2017 mac to make me a Windows exe.
There is a framework-dependent deployment assuming your friends have .net core runtime, they can also run with "dotnet blah.dll"
Otherwise you need to configure self-contained deployment using dotnet publish -c release -r win10-x64 command and some project configuration. More details are available at dotnet publish MSDN article and deployment strategies overall
You need to have a runtime identifier in your csproj for Windows in order for a Windows-compatible binary to be generated. Similar for various Linux distributions.
A list of IDs can be found at: https://learn.microsoft.com/en-us/dotnet/core/rid-catalog. For example, to target Windows 10 x64 you would use win10-x64.
Once you have the csproj configured and have rebuilt you should see a win10-x64 folder in your build output that will contain the files you need.
I have run through the boot2docker virtual machine setup tutorial in the docker toolbox https://www.docker.com/toolbox.
Using window 10 as my base, I managed to get virtualbox running from kitematic with Linux default 4.0.9-boot2docker
When I start trying to run apt-get or yum to install things like NODE.JS or ASPNET I'm told that the files aren't found.
The end goal is to be able to run my aspnet docker images on my local environment.
Do I need to install aspnet, node, etc... on my docker server before I can start running aspnet docker images? If yes, how do I install them in the version of linux that has no apt-get or yum?
edit - note it is the ASPNET core documentation that seems to suggest I need to install things on the docker server. https://dotnet.readthedocs.org/en/latest/getting-started/installing-core-linux.html perhaps I can docker-build within the windows environment and docker-run from the linux VM without actually installing anything other than my docker image?
With docker you can focus on using application, not installation.
you needn't waste time on application installation that you can pull the image directly to get node.js or aspnet environments work in minutes.
So answer your question, you can have these environments ready via pull command:
docker pull node
docker pull microsoft/aspnet