Reputation: 1239
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.
Upvotes: 27
Views: 27103
Reputation: 4609
Another solution would be to set IsPublishable
in csproj.
I 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.
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<IsPackable>false</IsPackable>
<IsPublishable>false</IsPublishable>
<Configurations>prod;stage;dev</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
Upvotes: 14
Reputation: 811
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.
Upvotes: 3
Reputation: 33
Maybe late to the party but in order to have control over what projects to publish, you could unlink the "Path to project(s)" variable (by clicking on "Link settings"). That makes the field editable and you can specify your desired .csproj.
Upvotes: 0
Reputation: 843
You can use dotnet publish <Path to .csproj>
. This will build and publish only the specified project and projects it depends on.
In order to specify a project in the '.Net Core' task with the command 'publish' you have to uncheck 'Publish Web Projects'.
Upvotes: 36
Reputation: 3239
This is decided on Project Dependencies for each projects.
In other words, there are some configuration to say that "which project need to build first, in order to let your target project successfully build."
If you are using Visual Studio, right click on solution and click 'Properties'.
In 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.
If 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
<Project Sdk="Microsoft.NET.Sdk.Web">
...
<ItemGroup>
<ProjectReference Include="..\TestAngular.Web.Core\TestAngular.Web.Core.csproj" />
</ItemGroup>
...
</Project Sdk="Microsoft.NET.Sdk.Web">
Add or remove which projects are not required here following same syntax
Upvotes: 2