Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to exclude projects to publish when publishing from a solution file? #13365

Closed
Nirmal4G opened this issue Jul 12, 2019 — with docs.microsoft.com · 10 comments
Closed
Assignees
Labels
cli/subsvc Pri1 High priority, do before Pri2 and Pri3 product-question Product usage related questions [org][type][category] support-request Support-style question;customer needs help solving a problem [org][type][category]
Milestone

Comments

Copy link

I have so many projects in the solution but when using publish, all the projects are published, I want to exclude the tests and other projects that don't need to publish or build.

Is there a way to do within a solution file by configuring it within Visual Studio IDE?

Is there a way to do it from MSBuild cmd options or dotnet publish cmd options.

Note: All projects are .NET Core and SDK-style projects. I'm using VS 16.1


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@Thraka
Copy link
Contributor

Thraka commented Jul 12, 2019

Hi! Thanks for the question. Doing a few searches web I came up with the following options:

  1. use the dotnet publish command and specify the project directly. This will only publish that project and exclude everything else.
  2. Use Visual Studio to create a publish profile. Right-click on the project and click Publish. You can use the dialog to create and save a publish profile. Use that profile with dotnet publish /p:PublishProfile=FileName

I'm going to close this issue. Let me know if you have more questions. You may have better luck asking on StackOverflow to broaden who looks at your question. Then if you have feedback on how to improve the documentation, you can submit a PR or file a new issue with the recommendation.

@Thraka Thraka closed this as completed Jul 12, 2019
@Thraka Thraka added product-question Product usage related questions [org][type][category] support-request Support-style question;customer needs help solving a problem [org][type][category] and removed ⌚ Not Triaged Not triaged labels Jul 12, 2019
@Thraka Thraka added this to the July 2019 milestone Jul 12, 2019
@Nirmal4G
Copy link
Author

Any docs for configuring solution file within Visual Studio IDE?

@Thraka
Copy link
Contributor

Thraka commented Jul 16, 2019

That question is best researched and asked on the Visual Studio documentation.

Cheers!

@Nirmal4G
Copy link
Author

After a lot of searching in the Targets, I found these properties IsPublishable and DeployOnBuild. They are self explanatory. For those who are a bit technical.

The IsPublishable property disables the Publish target itself. So no Build too! Since, Publish depends on Build.

The DeployOnBuild on the other hand uses your PublishProfile property to, you know, deploy the published files.

@Nirmal4G
Copy link
Author

@Thraka Please link the above comment, to those who are facing the same issues.

I'll put a PR on the relevant pages with the properties I mentioned above and similar others when I need them enough to find them. 😁

@Thraka
Copy link
Contributor

Thraka commented Jul 17, 2019

Good hunting! I didn't find much on it. So did setting DeployOnBuild to false work for you? I'll assign this issue to you since you indicated you wanted to open a PR.

@ggirard07
Copy link

Tried the IsPublishable property to false on an ASP.Net Core integration test project, but this result in the following error during the publish command:

C:\Program Files\dotnet\sdk\2.2.402\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(49,5): error MSB4018: The "TransformWebConfig" task failed unexpectedly. [C:\My\My.Solution\test\My.Solution.FunctionalTests\My.Solution.FunctionalTests.csproj]
C:\Program Files\dotnet\sdk\2.2.402\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(49,5): error MSB4018: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\My\My.Solution\test\My.Solution.FunctionalTests\My.Solution.FunctionalTests\patate\patator\web.config'. [C:\My\My.Solution\test\My.Solution.FunctionalTests\My.Solution.FunctionalTests.csproj]
C:\Program Files\dotnet\sdk\2.2.402\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(49,5): error MSB4018:    at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle) [C:\My\My.Solution\test\My.Solution.FunctionalTests\My.Solution.FunctionalTests.csproj]
C:\Program Files\dotnet\sdk\2.2.402\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(49,5): error MSB4018:    at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options) [C:\My\My.Solution\test\My.Solution.FunctionalTests\My.Solution.FunctionalTests.csproj]
C:\Program Files\dotnet\sdk\2.2.402\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(49,5): error MSB4018:    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) [C:\My\My.Solution\test\My.Solution.FunctionalTests\My.Solution.FunctionalTests.csproj]
C:\Program Files\dotnet\sdk\2.2.402\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(49,5): error MSB4018:    at Microsoft.NET.Sdk.Publish.Tasks.TransformWebConfig.Execute() [C:\My\My.Solution\test\My.Solution.FunctionalTests\My.Solution.FunctionalTests.csproj]
C:\Program Files\dotnet\sdk\2.2.402\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(49,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\My\My.Solution\test\My.Solution.FunctionalTests\My.Solution.FunctionalTests.csproj]
C:\Program Files\dotnet\sdk\2.2.402\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(49,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [C:\My\My.Solution\test\My.Solution.FunctionalTests\My.Solution.FunctionalTests.csproj]

@Thraka
Copy link
Contributor

Thraka commented Sep 20, 2019

@ggirard07 You may have better luck asking on StackOverflow or the Visual Studio Community or an ASP.NET Core forum of some kind or even the .NET Core CLI github repo. We're not really a support team and it's hard for us to find time to help out with problem questions. Your issue sounds like it can't find a web.config file it expects to find.

Unrelated to your comment @ggirard07 , I'm closing this PR as @Nirmal4G has not responded about opening a PR with some information.

@andrx
Copy link

andrx commented Nov 14, 2019

IsPublishable worked for me. thanks!

@alexis-landrieu-avanade

IsPublishable worked for me as well, thanks. I just share a quick example with MyUnitTestProject.csproj (that could help someone):

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>

    <IsPublishable>false</IsPublishable>
  </PropertyGroup>
...
</Project>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli/subsvc Pri1 High priority, do before Pri2 and Pri3 product-question Product usage related questions [org][type][category] support-request Support-style question;customer needs help solving a problem [org][type][category]
Projects
None yet
Development

No branches or pull requests

8 participants