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

Fix ResolveProjectReferences MSBuild target. #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

drolevar
Copy link

@drolevar drolevar commented Mar 1, 2021

When building a solution from command line with MSBuild later than 4.0 it doesn't build the complete project tree like it used to do before.
So GetTargetPath might be called before the project is built, which in certain situations leads to an error.
I have discovered this issue when I was doing a command line build of the solution, where WiX projects were referencing Dotfuscator-enabled C# projects. And in this case ResolveProjectReferences target from wix.targets was calling GetTargetPath on such Dotfuscator-enabled projects, which was triggering a dotfuscation before the project was built. This failed of course.

@@ -351,7 +350,7 @@
Projects="@(_MSBuildProjectReferenceExistent)"
Targets="%(_MSBuildProjectReferenceExistent.Targets);GetTargetPath"
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration);%(_MSBuildProjectReferenceExistent.SetPlatform)"
Condition="('$(BuildingSolutionFile)' == 'true' or '$(BuildingInsideVisualStudio)' == 'true' or '$(BuildProjectReferences)' != 'true') and '@(_MSBuildProjectReferenceExistent)' != '' "
Condition="('$(BuildingInsideVisualStudio)' == 'true' or '$(BuildProjectReferences)' != 'true') and '@(_MSBuildProjectReferenceExistent)' != '' "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking at this. v3 created this since we didn't use Common.targets, but in v4 we are using it. This target probably needs to match the canonical version at https://github.com/dotnet/msbuild/blob/83cd7d4e36b71d5b2cefd02cb9a5a58d27dd6a75/src/Tasks/Microsoft.Common.CurrentVersion.targets#L1914. It would be nice if we could extend that one instead of overwriting it with our own.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rseanhall I totally agree. Do you think it'll be sufficient to run standard ResolveProjectReferences and then filter out Wix library references into WixLibProjects?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was probably going to defer to others to handle this PR since I have no knowledge of what the customization is supposed to be doing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a very large work item post 4.0-preview.0 to review our .target files from top to bottom. There are many little problems that sum up to a larger feeling that there is a large re-work required. At this time, I'm inclined to leave this line here as a throwback to WiX v3 that should be accounted (and every possibly tossed).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're not going to fix this properly in 4.0-preview.0, then if someone does the work to put our customization inside the latest ResolveProjectReferences from Common.targets then I think we should take it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wixlib stuff is generation of Wixlib references. And it's still being done in the ResolveWixLibraryReferences target which is called after the vanilla ResolveProjectReferences.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robmen @barnson @rseanhall Do you have ancient Wix source? I'd like to investigate the evolution of wix.targets before v3.8.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/wixtoolset/codeplex

OK. So there are two commits which distinguish ResolveProjectReferences from the vanilla version (apart from the wixlib filtering).

The biggest one is wixtoolset/codeplex@9781a18.
Here the comment from @robmen says Add support to build only .wixlib project references.
Correct me if I'm wrong, but apparently this is not used anywhere. I haven't seen any place in the code, neither present nor past where BuildProjectReferences is set to wixlib. That was almost exactly 10 years ago.

The next one is wixtoolset/codeplex@975c902.
Apparently, this a workaround for the bug described here: https://devblogs.microsoft.com/visualstudio/incorrect-solution-build-ordering-when-using-msbuild-exe/
However, I need to confirm it.

Other then that, it's only the mentioned logic for populating WixLibProjects which I moved to ResolveWixLibraryReferences.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rseanhall Reimplemented according to your suggestion. wixtoolset/codeplex@975c902 was necessary, so had to keep the old structure.

@robmen
Copy link
Member

robmen commented Mar 4, 2021

@drolevar would you consider capturing this as an issue so your scenario is included in my round-up of all MSBuild issues?

@rseanhall
Copy link
Contributor

I wonder if this is the root cause behind wixtoolset/issues#6290.

@drolevar drolevar force-pushed the fix_msbuild_targets branch 2 times, most recently from df5d501 to 52dcf94 Compare March 9, 2021 10:42
@drolevar
Copy link
Author

drolevar commented Mar 9, 2021

I wonder if this is the root cause behind wixtoolset/issues#6290.

By the way, it seems to fix this issue. At least if I remove the workaround target, it seems to build and all the tests complete successfully.

@drolevar drolevar force-pushed the fix_msbuild_targets branch from 52dcf94 to c70e122 Compare March 10, 2021 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants