Skip to content

Update Test target #85

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

Merged
merged 2 commits into from
Apr 12, 2024
Merged

Update Test target #85

merged 2 commits into from
Apr 12, 2024

Conversation

mthalman
Copy link
Member

This is related to the work for dotnet/installer#19222. It updates the existing Test target to include more functionality so that this logic doesn't need to be defined outside by the VMR.

@mthalman mthalman requested a review from mmitche April 11, 2024 19:46
<TestArgs>$(TestArgs) --test-root "$(TestRoot)"</TestArgs>
<TestArgs>$(TestArgs) $(AdditionalTestArgs)</TestArgs>

<_MSBuildSdksDir>/%(_DotNetPath.Directory)Sdks</_MSBuildSdksDir>
Copy link
Member

Choose a reason for hiding this comment

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

Is the '/' prefix intentional here? Could use use Path.Combine instead?

Copy link
Member

Choose a reason for hiding this comment

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

Would it be better to construct this path from the NETCoreSdkVersion and dotnet root? If there are multiple SDKs installed, you'll always get the last one in the itemgroup, which may not match with --sdk-version.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed. I realized that NETCoreSdkVersion won't be set correctly in the context of the VMR. It will be set to the global.json version, not the version we're testing. So the call from the VMR can override NETCoreSdkVersion to resolve this.

@mthalman mthalman requested a review from mmitche April 12, 2024 17:31
@mthalman mthalman merged commit 4e95e33 into dotnet:main Apr 12, 2024
@mthalman mthalman deleted the msbuild-test branch April 12, 2024 18:33
Comment on lines +14 to +41
<Target Name="CreateDirectoryBuildFiles">
<!-- Define Directory.Build.* files in the scenario tests artifacts directory to prevent the test run from
picking up the configuration from the VMR's Directory.Build.* files. We need an isolated configuration
from which to test. -->
<WriteLinesToFile File="$(TestRoot)Directory.Build.targets"
Lines="&lt;Project /&gt;"
Overwrite="true" />
<!-- Because the VMR (https://github.com/dotnet/dotnet) is configured to use CPM (https://github.com/dotnet/installer/pull/19286), it will
cause the scenario tests to fail with the following error:
Projects that use central package version management should not define the version on the PackageReference items but on the PackageVersion items: ...
To work around this, we explicitly disable CPM. Note that this can't be solved by including a stub Directory.Packages.props file because the default
behavior is to automatically default ManagePackageVersionsCentrally to true when it finds such a file.
https://github.com/NuGet/NuGet.Client/blob/ca13cf0a281b9774dd0238a43ab98c1927056cc2/src/NuGet.Core/NuGet.Build.Tasks/NuGet.props#L25-L33 -->
<PropertyGroup>
<_DirectoryBuildPropsContent>
&lt;Project&gt;
&lt;PropertyGroup&gt;
&lt;ManagePackageVersionsCentrally&gt;
false
&lt;/ManagePackageVersionsCentrally&gt;
&lt;/PropertyGroup&gt;
&lt;/Project&gt;
</_DirectoryBuildPropsContent>
</PropertyGroup>
<WriteLinesToFile File="$(TestRoot)Directory.Build.props"
Lines="$(_DirectoryBuildPropsContent)"
Overwrite="true" />
</Target>
Copy link
Member

Choose a reason for hiding this comment

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

Just saw this PR. I think it might be cleaner to just set the following env vars or properties in the generated projects: ImportDirectoryBuildProps=false ImportDirectoryBuildTargets=false and ImportDirectoryPackagesProps=false. That avoids creating these intermediate files and removes the need for this target.

We do that for the smoke tests that also create intermediate projects: https://github.com/dotnet/dotnet/blob/212c615a6283f3904a2e78b1a56d30363bc11634/test/Microsoft.DotNet.SourceBuild.SmokeTests/DotNetHelper.cs#L133-L136

Copy link
Member

@ViktorHofer ViktorHofer Jul 2, 2024

Choose a reason for hiding this comment

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

@mthalman just double checking, did you follow-up on this feedback or do we have a tracking issue for it?

Asking as the current approach causes issues (i.e. dotnet/sdk#41895 failed because the VMR root's Directory.Packages.props file still gets imported).

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, no, I missed that. I've logged dotnet/source-build#4489.

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