Where are my output DLLs when publishing an ASP.NET 5 web application?
When running the MSBuild's FileSystemPublish, the publish directory looks something like this:
approot folder: packages, runtime and source code
wwwroot folder: web.config and AspNet.Loader.dll
web
web.cmd
MSBuild.exe "C:/MyApplication/MyProj.xproj" /t:Build,FileSystemPublish /p:PublishConfiguration=Release /p:PublishOutputPathNoTrailingSlash="C:/a/MyApplication"
From the logging output I can see that dnu publish is called:
dnu publish "C:/MyApplication" --out "C:/a/MyApplication" --configuration Release --runtime dnx-clr-win-x86.1.0.0-beta6 --quiet
If I look inside web.cmd I can see that DNX is indeed running the application from source code:
#"%~dp0approot\runtimes\dnx-clr-win-x86.1.0.0-beta6\bin\dnx.exe" --appbase "%~dp0approot\src\MyApplication" Microsoft.Framework.ApplicationHost web %*
I am able to point IIS to the wwwroot directory with success.
How does IIS know to call on web.cmd? Is this the correct approach to serving up an ASP.NET 5 application in a production environment?
IIS doesn't call web.cmd. IIS knows how to load AspNet.Loader from the wwwroot folder.
In a production environment you probably don't want to compile from sources because the startup is pretty slow. You should publish precompiled binaries. You do that by passing --no-source to dnu publish:
dnu publish "C:/MyApplication" --out "C:/a/MyApplication" --configuration Release --runtime dnx-clr-win-x86.1.0.0-beta6 --no-source
The question is obsolete
According to the latest community standup (see Announcement), the HELIOS integration between IIS and asp.net 5 was stopped. Ongoing the only server provided by MS is kestrel. IIS will natively not recognize DNX projects.
You have to start and integrate kestrel into IIS by reverse proxying it using the HttpPlatformHandler (IIS8+).
Related
When using the command
dotnet build /p:DeployOnBuild=true /p:PublishProfile=CustomProfile
my ASP.NET Core project builds and gets published using the FileSystem publishing method.
When I use the
dotnet publish /p:PublishProfile=CustomProfile
command (which should do the publish part only) the build part gets done but no publish actions are done.
Is this a limitation from dotnet?
Is there a workaround?
My system:
dotnet --version
3.1.201
VS2019 16.5.3
I have a .NET Core Web Application. I'm using the publish command to create a self contained deployment.
It creates the files and appears to create .net core dlls, but when runnning in IIS on Windows 10, I still need to install the .NET Core Runtime to get it to work. After installing .NET Core Hosting bundle it works fine.
I have reviewed a lot of other posts before asking, but can't find the answer.
By default IIS gives the following error:
HTTP ERROR 500.19 – Internal Server Error
My Publish command:
dotnet publish "mydirectory\mywebsite.csproj" --self-contained --framework netcoreapp2.1 -r win10-x64 -c Release
The csproj looks like this:
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<UserSecretsId>aspnet-mywebsite-656GASF8-B9H4-5963-1038-5D735B609E15</UserSecretsId>
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
</PropertyGroup>
Here are the published files.
I thought maybe the 'l1-1-0' part might be the wrong framework version, but my dotnet version is 2.1.500.
What do I need to do to get it to work please?
Lex Li's comment/ blog post contains the answer. I'm detailing it here to try to save someone else losing days to this simple misunderstanding.
A self contained deployment does indeed include the runtime, but
it doesn't include the ASP.NET Core module for IIS which you get
when you download the Runtime & Hosting Bundle from the .net downloads
page.
So if you are deploying to IIS, you will need to run the Runtime & Hosting Bundle installer even for a self contained deployment.
A self contained deployment just means the application will use the .NET Core Runtime packaged with the application rather than whatever is installed on the machine.
I have a problem with a dotnet core project of mine. I have a TFS build that does a "dotnet publish" and deploys the application to IIS.
The publish command looks like this:
dotnet publish -o $(build.stagingDirectory) -c Release --self-contained --runtime win81-x64
My code hasn't changed but now I get the following error when I run the build on the TFS:
NETSDK1067: Self-contained applications are required to use the application host. Either set SelfContained to false or set UseAppHost to true.
We updated the build server to the newest .NET Core SDK last week so I guess it probably has something to do with that.
What changed and what can I do to make the build work again?
I try to build and publish my .NET Core applications on the command line using predefined publish profiles.
For a ASP.NET Core application this (taken from here) works:
dotnet build -c Release /p:DeployOnBuild=true /p:PublishProfile=ReleaseFolder
But for a console application (where the publish profile is called FolderProfile, the following does not work:
dotnet build -c Release /p:DeployOnBuild=true /p:PublishProfile=FolderProfile
It builds the project but does not publish it.
So how can I publish a console application using a predefined publish profile?
Publish profile support is part of the web-SDK which is used by the web targets. ASP.NET Core applications typically use the Microsoft.NET.Sdk.Web wheres console applications use the Microsoft.NET.Sdk project.
Since console applications therefor don't include the web SDK's publishing support, you can only use the Publish target which generates deployable outputs. It is wrapped by the dotnet cli's dotnet publish command and can alternatively be used as msbuild /t:Publish. This publish command has no support for publish profiles since it is only a filesystem based operation.
You can now add the Microsoft.NET.Sdk.Publish sdk to your project file. That will enable you to use dotnet publish for your project.
<Project Sdk="Microsoft.NET.Sdk;Microsoft.NET.Sdk.Publish">
I'm having some trouble understanding how to publish an ASP.NET Core application to a server using Webdeploy on TeamCity.
I've installed the dotnet core teamcity plugin and have two build steps:
dotnet restore (as a command line step, the built in step timesout on nuget)
dotnet publish src/projectName/projectName.csproj
However I'm confused as to what to do for the third step, which is to publish the result of dotnet publish to our server.
Traditionally we'd use MSBuild and target a publish profile, however I'm unsure whether .NET core utilises MSBuild.
I've got a publish profile as part of my solution which works successfully within VS2017. I've had a look at the TeamCity blog which discusses setting up TeamCity to use .NET Core, and whilst it does mention WebDeploy, it just simply mentions it can be used alongside dotnet publish without really explaining how.
However I'm confused as to what to do for the third step, which is to publish the result of dotnet publish to our server.
Traditionally we'd use MSBuild and target a publish profile, however I'm unsure whether .NET core utilises MSBuild.
I've also found documentation on automated .NET Core deployment lacking. Generally for deploying to IIS you have two options.
You can still use MSBuild with /p:DeployOnBuild=true to deploy a .pubxml publish profile created in Visual Studio as with .NET framework sites. Run MSBuild after dotnet restore and instead of dotnet publish.
Or you can also use dotnet publish to publish to a folder, and msdeploy.exe to sync that folder to an IIS site, possibly on a remote machine. Typically:
msdeploy.exe -verb:sync -source:contentPath="<the folder published to by dotnet publish>" -dest:contentPath=<Your IIS Site>
I've using the next command to create web deploy package:
dotnet publish <Path_and_name_of_project>.csproj --configuration Release /p:PublishProfile=<profile_name>
and after this step, i've deploy package to iis via webdeploy command