-
Notifications
You must be signed in to change notification settings - Fork 107
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
Skip projection generation during design-time build if inputs are missing #1105
Conversation
This problem can also happen when a WinMD is present but it's out of date.
I think we can solve this with a much simpler change, by simply setting COntinueOnError on the CsWinRT Exec task as follows:
Thoughts? |
@evelynwu-msft does this fix #1056 and/or #963? |
@angelazhangmsft my suggested approach fixes #963 |
My preference is to skip the scenario entirely if we know in advance that it's going to generate an error. It minimizes the amount of unnecessary work that is done, and avoids the possibility of cswinrt.exe, even in an error situation, leaving behind cruft that pollutes the build outputs. (It's also not clear to me from the MSDN documentation if |
@angelazhangmsft Yes, I believe it would address both of them. |
Skipping the scenario makes the IDE experience worse as you get no intellisense until you do a build. That doesn't seem like the right way forward. |
Per docs here https://docs.microsoft.com/en-us/visualstudio/msbuild/onerror-element-msbuild?view=vs-2022#remarks OnError will be skipped but this is fine. If the inputs don't change, the target wouldn't create any other output either way and once any of the inputs are generated the target would be run again, because the input changed. |
Wouldn't Intellisense information be missing regardless because |
From observation and experience it still generates the partial projection up to the point it hits the error, so you'd get some intellisense. |
Note that the fix as proposed in this PR doesn't completely address #693. The designtime build can still fail for a reason other than a missing output file, for example a missing project reference to a WinMD containing types used by a different WinMD. In that case there are no missing files as far as the logic is concerned and so the Designtime build would still fail, causing all the same problems. |
…rely during DTB if inputs are missing (PR feedback)
1f5bad8
to
1db254d
Compare
@jlaanstra Your suggestion worked! |
LGTM /cc @Scottj1s |
Although it is generally desirable for CsWinRT projection generation to explicitly fail if input
.winmd
s are missing, we don't want this to happen during a design-time build. Due to Visual Studio's architecture, failures in a project's design-time build can leave the results of dependent projects' design-time builds in an inconsistent state (this was determined to be one of the primary root causes of https://task.ms/37142724). An example of this scenario would be a CsWinRT project that depends on a C++/CX Windows Runtime Component project: the latter produces its output.winmd
during theLink
target and so the.winmd
does not exist for the former to consume until a normal build has completed.This change modifies the
CsWinRTGenerateProjection
target to skip thecswinrt.exe
command if it is determined that (a) it is currently running in the context of a design-time build, and (b) one or more of the input.winmd
s does not exist. This allows the design-time build to succeed while still allowing for the possibility of a legitimate failure during a normal build.