-
Notifications
You must be signed in to change notification settings - Fork 1.2k
allow publish solutions with non-publishable multi-target projects #10659
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
Conversation
Taken you have have a solution with two projects: 1. class library, multiple target frameworks (e.g. netstandard2.1;net461) 2. console application, one target framework (e.g. netcoreapp3.1) Currently we cannot run "dotnet publish" on solution level because of the error in `Microsoft.NET.Sdk.CrossTargeting.targets`. This is true, even if the class library is marked as `<IsPublishable>false</IsPublishable>`. Currently you have call publish just for console project (2). This isn't simple in more generic scenarios or in larger solutions with multiple projects having different target opt-in/opt-out settings defined only by project properties (like `IsPublishable`, `IsPackable`, `IsTestProject`, `RuntimeIdentifier` etc.) There is no need to throw a "cannot publish error" message for projects not to be published at all. This change should fix this. See dotnet#1059 (comment)
7537440
to
d8ba7a5
Compare
Here's some unit test showing the problem. I couldn't make the unit test stable / working on my machine out of the box, therefore this is just a comment -- maybe needs some polishing.
|
@StefanBertels Can you fix the merge conflicts and look at adding a test for this scenario and then we can accept the change? Thanks. |
I hope someone can take on this, it's still an issue with net5.0. Meanwhile a workaround is to add this to the csproj (for Microsoft.NET.Sdk projects with multiple target frameworks):
Note: this hack will result in warnings. |
Reviewing older PRs, I realized that we already got this fixed: #15402. Thanks for raising the visibility. |
Taken you have have a solution with two projects:
netstandard2.1;net461
)netcoreapp3.1
)Currently we cannot run "dotnet publish" on solution level because of the error in
Microsoft.NET.Sdk.CrossTargeting.targets
.This is true, even if the class library is marked as
<IsPublishable>false</IsPublishable>
.Currently you have call publish just for console project (2). This isn't simple in more generic scenarios or in larger solutions with multiple projects having different target opt-in/opt-out settings defined only by project properties (like
IsPublishable
,IsPackable
,IsTestProject
,RuntimeIdentifier
etc.)There is no need to throw a "cannot publish error" message for projects not to be published at all. This change should fix this.
See #1059 (comment)