-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 check if the current invocation is running publish
?
#26324
Comments
There isn't a way to tell what targets MSBuild will run (before it actually runs them), so there's not a good way to do this. On the other hand, we would like to be able to have different defaults and behavior between build and publish. The first step toward that just went in with #25991. With that change, you could check the |
@dsplaisted are there plans (or even capability) to set ispublishing when using the /t flag? Not sure what this issue tracks with 25991 merged now. |
No concrete plans I think. We could detect and handle something like |
yeah, this is a sort of general problem we're hitting with all of these 'use publish to push better packaging practices'-style features - the gulf between |
I think the |
Aside -- could we just set |
In that case it wouldn't be set during MSBuild evaluation or in targets that run before publish. So I think in most cases it would be set way later than you would need to check it. |
I see, in that case I could also set it to true in the Publish target in case of |
No, see this discussion here: it (referring to |
One suggestion is to capture anything specified through -t: on the commandline into a global property that's a semicolon separated list thing Noah took care of |
Hey, I stumbled on this issue, as I wanted to set But I'm wondering why it would not be desirable to have |
@xoofx @/rainersigwald can provide a better explanation than me but I will give it an attempt. It is 'impossible' to know for sure which target is going to run early enough for MSBuild itself to take action. One reason is that people can implement their own custom targets that call publish or build later, so from the beginning of evaluation we cannot check the MSBuild target stack to see if Publish is in the target-stack. Another reason is that properties like We would love to have the ability to do so, and in fact I directed a meeting with others to discuss if we could, the above is the end result of that meeting. VS and Dotnet are different because when you invoke dotnet publish you explicitly know before evaluation that you're doing a publish, same when you click the button in VS. (Though BTW, ❤️ Unity |
Thanks for the explanation @nagilson, I appreciate the details!
Indeed, I understand that it's safer to plug it in the dotnet command. If I recall, it's not the only property that some commands are already setting or that the interaction with MSBuild is tweaked from there (e.g build => restore + build in separate steps) Hope that
Same, will love it even more once we have migrated to .NET 7/8 + MSBuild! 😄 |
Did we consider doing a breaking change and erroring out in the The problem is that we're getting more and more build customizations conditioned under |
@MichalStrehovsky We never considered that. I can see the logic behind it, though it would break a large number of customers and probably cause frustration. That being said, it is an interesting idea to solve this issue that you mention regarding _IsPublishing. |
https://github.com/search?q=_IsPublishing+language%3AXML&type=code&l=XML - looks like many third parties depend on I guess the question is at what point will We're starting to get blocked internally on things because |
Wow. Anyway, I think your point is interesting. Since @rainersigwald owns MS Build I think he would have to have a say on what we'd do here, as well as our PMs. But its something we could consider. |
Definitely not a 'good first issue' |
Title basically says it all -- but in certain cases I'd like to know in the project file whether we're doing a build or a publish. In particular, I might want a non-self-contained build by default, but always want a self-contained publish.
The text was updated successfully, but these errors were encountered: