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
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Hi! Thanks for the question. Doing a few searches web I came up with the following options:
dotnet publish command and specify the project directly. This will only publish that project and exclude everything else.dotnet publish /p:PublishProfile=FileNameI'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.
Any docs for configuring solution file within Visual Studio IDE?
That question is best researched and asked on the Visual Studio documentation.
Cheers!
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.
@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. 😁
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.
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]
@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.
IsPublishable worked for me. thanks!
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>
Most helpful comment
IsPublishableworked for me as well, thanks. I just share a quick example with _MyUnitTestProject.csproj_ (that could help someone):