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">
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 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 have a two net core console apps that I deploy to Azure as web jobs using visual studio.
<Project Sdk="Microsoft.NET.Sdk;Microsoft.NET.Sdk.Publish">
It works well, when I publish them separately.
How do I publish .net core webjobs togeter with web app?
I have tried create webproject/properties/webjob-list.json. Paths are relative to webproject/webproject.csproj:
{
"$schema": "http://schemastore.org/schemas/json/webjobs-list.json",
"WebJobs": [
{
"filePath": "../PeopleWebJob/PeopleWebJob.csproj"
},
{
"filePath": "../Reminder/ReminderWebJob.csproj"
}
]
}
I've also tried to install Microsoft.Web.WebJobs.Publish nuget, but it looks like this approach is not working for .NET Core.
Alternativelly,
How do I publish the webjobs using VSTS?
I've tried to dotnet publish the WebJob project and copy the output to $(Build.ArtifactStagingDirectory)/webproject.zip/App_Data/jobs/Triggered
It is not supported for VS to deploy WebJobs along with .NET Core Apps yet.
This is a similar issue, you could refer to it. To publish the webjobs via VSTS, you could refer to this link.
Besides, you can also zip it up and use the Azure Portal to create the WebJob or use Kudu Console or FTP to do it.
Since you copy the necessary output to webproject.zip/App_Data/jobs/Triggered (do not zip published web project during dotnet publish, then copy files and zip files through Archive Files task), you just need to publish the project through Azure App Service Deploy task.
Package or folder: {the website zip file}
Check Publish using Web Deploy option in Additional Deployment Options section
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
The following is so so simply and yet it fails. What's wrong?
I create a new ASP.NET Core Web Application (.NET Framework 4.6.2) in Visual Studio 2017.
I make no changes to the default template and I push it to VSTS.
I create a new build definition in VSTS with the following two steps:
NuGet Restore
Visual Studio Build
I update the NuGet step to use version 4.0.0
I update the definition to use the Hosted VS2017 agent.
I leave the Build step using VS2017 with the default MSBuild arguments:
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\".
In previous versions this would create me a web deployment package which is exactly what I want.
I queue a new build.
The NuGet step succeeds.
The build step runs until it logs...
_TransformWebConfig:
...and then...
No web.config found. Creating 'C:\a\1\s\src\WebApp\obj\Release\net462\win7-x86\PubTmp\Out\web.config'
...and...
Microsoft.NET.Sdk.Publish.MSDeployPackage.targets(124,7): Error MSB4184: The expression "[System.IO.Path]::GetDirectoryName('')" cannot be evaluated. The path is not of a legal form.
This issue has been fixed: https://github.com/aspnet/websdk/issues/106
Sample commandline and syntax to use in VSTS (ASPNET Core templates should already have this in the template): https://github.com/vijayrkn/ASPNetPublishSamples/blob/bff9f78d796668dc07d5e28a8b93531caade839c/Publish.cmd#L102-L127
You can use ASP.NET Core (Preview) build template, it publishes the .Net Core app through dotnet tool.
Create a new build definition
Select ASP.NET Core (Preview) build template
I think the follwing article has the answer.
https://www.visualstudio.com/en-us/docs/build/apps/aspnet/aspnetcore-to-azure.
In summary, don't use Visual Studio to do the build, use the CLI instead, i.e.
dotnet.exe publish -c $(BuildConfiguration) -o $(Build.ArtifactStagingDirectory)