Skip to content

Conversation

Evangelink
Copy link
Member

Description

Update sourcebuild configuration so we generate both net previous and net current to help with multi-insertion (today we insert both in net8 and net9). The fix is based on my understand of this comment dotnet/sdk#37983 (comment) but it's possible we will have to do a few iterations to have it all right.

Related issue

This should be fixing dotnet/sdk#37983

@MichaelSimons
Copy link
Member

Capturing a conversation @Evangelink and I had offline.

The reported prebuilts are implicitly loaded by the SDK. Since the projects are now targeting NetPrevious, these packages are not available in the source-build graph and thus reported as a prebuilt. With the suggestion I provided in #4856 (comment), it would be acceptable to add these as allowed prebuilts in the SourceBuildPrebuiltBaseline.xml because these are only referenced in CI and not the actual product build.

@Evangelink Evangelink enabled auto-merge (squash) January 29, 2024 16:41
Co-authored-by: Michael Simons <msimons@microsoft.com>
@Evangelink Evangelink disabled auto-merge January 29, 2024 18:24
@Evangelink Evangelink merged commit 98c26a1 into microsoft:main Jan 29, 2024
targeting NetCurrent or NetPrevious hence we must produce both.
-->
<PropertyGroup Condition=" '$(DotNetBuildFromSource)' == 'true' AND '$(DotNetBuildFromSourceFlavor)' != 'Product' ">
<TargetFrameworks>$(NetPrevious);$(NetCurrent)</TargetFrameworks>
Copy link
Member

@ViktorHofer ViktorHofer Jan 31, 2024

Choose a reason for hiding this comment

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

Even when looking at the PR description I don't understand why vstest needs to build NetPrevious under source-build when not building the product. Why is that?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because we insert in both net8 and net9 and it's causing some insertion. That's the solution recommended by @MichaelSimons.

Copy link
Member

Choose a reason for hiding this comment

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

This issue is that the dependent repos (e.g. SDK) target different TFM depending on the version. Therefore to support the repo level source-builds, this repo has to target multiple TFMs. This pattern is used in other repos like roslyn.

Fair feedback regarding documentation/tracability.

Copy link
Member

@ViktorHofer ViktorHofer left a comment

Choose a reason for hiding this comment

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

This change seems to have regressed the source-build product build: dotnet/installer#18457.

@@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0</TargetFrameworks>
Copy link
Member

Choose a reason for hiding this comment

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

nit: This regresses perf as TargetFrameworks kicks-off an inner build from the outer build, even though the project is actually single-targeting. I would revert this change and instead find a better pattern in Directory.Build.props to override the TFM for source-build.

Copy link
Member Author

Choose a reason for hiding this comment

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

If you have some easy suggestion, I am happy to apply otherwise I fear that's not going to be a priority for me given the other tasks I have on my shoulders at the moment.

Copy link
Member Author

Choose a reason for hiding this comment

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

I couldn't find any easy trick to unset TargetFramework and replace it with TargetFrameworks in case of source build.

nohwnd added a commit to nohwnd/vstest that referenced this pull request Jan 31, 2024
@Evangelink Evangelink deleted the fix-source-build branch January 31, 2024 15:25
This was referenced Aug 26, 2025
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