Home:ALL Converter>dotnet publish only one project from the solution in VSTS

dotnet publish only one project from the solution in VSTS

Ask Time:2018-09-03T14:25:46         Author:Lassi Autio

Json Formatter

We are trying to build one project from a Visual Studio solution in VSTS with .NET Core task. We are able to "dotnet build" that project. But when we try to "dotnet publish" it tries to publish all projects from the solution. Even if we use "dotnet custom", it tries to publish all projects.

Is there a way to use .NET Core task to publish only one project or projects that were built? Or should we run a custom command line task?

Reason for this is that we have a project that won't build and we don't need/want to publish it. So we would like to build and publish one project and not all projects.

Screenshot from VSTS

Author:Lassi Autio,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/52144194/dotnet-publish-only-one-project-from-the-solution-in-vsts
renklus :

You can use dotnet publish <Path to .csproj>. This will build and publish only the specified project and projects it depends on.\n\nIn order to specify a project in the '.Net Core' task with the command 'publish' you have to uncheck 'Publish Web Projects'.",
2018-09-03T10:43:05
Andrey Borisko :

Another solution would be to set IsPublishable in csproj.\n\nI usually do it in cases where it's a unit test project or else that doesn't need to be published if you run dotnet publish for solution file.\n\n <PropertyGroup>\n <TargetFramework>netcoreapp2.2</TargetFramework>\n <IsPackable>false</IsPackable>\n\n <IsPublishable>false</IsPublishable >\n\n <Configurations>prod;stage;dev</Configurations>\n <Platforms>AnyCPU</Platforms>\n </PropertyGroup>\n",
2019-11-14T14:13:26
Ben D :

If you un-check the 'Publish Web Projects' you will see a field appear that allows you to enter the project (csproj) you want to target.",
2022-02-10T17:06:05
Jacky :

This is decided on Project Dependencies for each projects.\n\nIn other words, there are some configuration to say that \"which project need to build first, in order to let your target project successfully build.\"\n\nIf you are using Visual Studio, right click on solution and click 'Properties'.\nIn this example, my target run is TestAngular.Web.Host and in order to build that projects, it's required to build TestAngular.Web.Core first.\n\n\nIf you are using different IDE, simply locate to your directory, in my case it would be src\\TestAngular.Web.Host and modify TestAngular.Web.Host.csproj file\n\n<Project Sdk=\"Microsoft.NET.Sdk.Web\">\n...\n<ItemGroup>\n <ProjectReference Include=\"..\\TestAngular.Web.Core\\TestAngular.Web.Core.csproj\" />\n </ItemGroup>\n...\n</Project Sdk=\"Microsoft.NET.Sdk.Web\">\n\n\nAdd or remove which projects are not required here following same syntax",
2018-09-03T06:37:30
yy