Skip to content

Commit e21972a

Browse files
Remove test workaround that alters Sdk targets (#4205) (#4216)
Co-authored-by: Youssef Victor <[email protected]>
1 parent 979488a commit e21972a

File tree

1 file changed

+0
-231
lines changed

1 file changed

+0
-231
lines changed

test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/MSBuildTests.Solution.cs

Lines changed: 0 additions & 231 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,9 @@ public class MSBuildTests_Solution : AcceptanceTestBase
1111
private readonly AcceptanceFixture _acceptanceFixture;
1212
private const string AssetName = "MSTestProject";
1313

14-
static MSBuildTests_Solution()
15-
{
16-
string dotnetMuxerSDK = Directory.GetDirectories(Path.Combine(RootFinder.Find(), ".dotnet", "sdk")).OrderByDescending(x => x).First();
17-
File.WriteAllText(Path.Combine(dotnetMuxerSDK, "Microsoft.Common.CrossTargeting.targets"), MicrosoftCommonCrossTargeting);
18-
if (!File.Exists(Path.Combine(dotnetMuxerSDK, "Microsoft.Common.Test.targets")))
19-
{
20-
File.WriteAllText(Path.Combine(dotnetMuxerSDK, "Microsoft.Common.Test.targets"), MicrosoftCommonTesttargets);
21-
}
22-
}
23-
2414
public MSBuildTests_Solution(ITestExecutionContext testExecutionContext, AcceptanceFixture acceptanceFixture)
2515
: base(testExecutionContext) => _acceptanceFixture = acceptanceFixture;
2616

27-
private void CheckPatch()
28-
{
29-
// https://github.com/dotnet/sdk/issues/37712
30-
if (DateTime.UtcNow.Date > new DateTime(2024, 12, 1))
31-
{
32-
throw new InvalidOperationException("Check if we can remove the patch!");
33-
}
34-
}
35-
3617
internal static IEnumerable<TestArgumentsEntry<(string SingleTfmOrMultiTfm, BuildConfiguration BuildConfiguration, bool IsMultiTfm, string Command)>> GetBuildMatrix()
3718
{
3819
foreach (TestArgumentsEntry<(string SingleTfmOrMultiTfm, BuildConfiguration BuildConfiguration, bool IsMultiTfm)> entry in GetBuildMatrixSingleAndMultiTfmBuildConfiguration())
@@ -52,8 +33,6 @@ private void CheckPatch()
5233
[ArgumentsProvider(nameof(GetBuildMatrix))]
5334
public async Task MSBuildTests_UseMSBuildTestInfrastructure_Should_Run_Solution_Tests(string singleTfmOrMultiTfm, BuildConfiguration _, bool isMultiTfm, string command)
5435
{
55-
CheckPatch();
56-
5736
using TestAsset generator = await TestAsset.GenerateAssetAsync(
5837
AssetName,
5938
SourceCode
@@ -155,215 +134,5 @@ public void TestMethod1()
155134
global using Microsoft.Testing.Platform.Builder;
156135
global using Microsoft.Testing.Internal.Framework;
157136
global using Microsoft.Testing.Platform.MSBuild;
158-
""";
159-
160-
private const string MicrosoftCommonCrossTargeting = """
161-
<!--
162-
***********************************************************************************************
163-
Microsoft.Common.CrossTargeting.targets
164-
165-
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
166-
created a backup copy. Incorrect changes to this file will make it
167-
impossible to load or build your projects from the command-line or the IDE.
168-
169-
Copyright (C) Microsoft Corporation. All rights reserved.
170-
***********************************************************************************************
171-
-->
172-
<Project DefaultTargets="Build">
173-
<PropertyGroup>
174-
<BuildInParallel Condition="'$(BuildInParallel)' == ''">true</BuildInParallel>
175-
<ImportByWildcardBeforeMicrosoftCommonCrossTargetingTargets Condition="'$(ImportByWildcardBeforeMicrosoftCommonCrossTargetingTargets)' == ''">true</ImportByWildcardBeforeMicrosoftCommonCrossTargetingTargets>
176-
</PropertyGroup>
177-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.CrossTargeting.targets\ImportBefore\*.targets" Condition="'$(ImportByWildcardBeforeMicrosoftCommonCrossTargetingTargets)' == 'true' and exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.CrossTargeting.targets\ImportBefore')" />
178-
<Import Project="$(CustomBeforeMicrosoftCommonCrossTargetingTargets)" Condition="'$(CustomBeforeMicrosoftCommonCrossTargetingTargets)' != '' and Exists('$(CustomBeforeMicrosoftCommonCrossTargetingTargets)')" />
179-
<Target Name="GetTargetFrameworks" DependsOnTargets="GetTargetFrameworksWithPlatformFromInnerBuilds" Returns="@(_ThisProjectBuildMetadata)">
180-
<Error Condition="'$(IsCrossTargetingBuild)' != 'true'" Text="Internal MSBuild error: CrossTargeting GetTargetFrameworks target should only be used in cross targeting (outer) build" />
181-
<CombineXmlElements RootElementName="AdditionalProjectProperties" XmlElements="@(_TargetFrameworkInfo-&gt;'%(AdditionalPropertiesFromProject)')">
182-
<Output TaskParameter="Result" PropertyName="_AdditionalPropertiesFromProject" />
183-
</CombineXmlElements>
184-
<ItemGroup>
185-
<_ThisProjectBuildMetadata Include="$(MSBuildProjectFullPath)">
186-
<TargetFrameworks>@(_TargetFrameworkInfo)</TargetFrameworks>
187-
<TargetFrameworkMonikers>@(_TargetFrameworkInfo-&gt;'%(TargetFrameworkMonikers)')</TargetFrameworkMonikers>
188-
<TargetPlatformMonikers>@(_TargetFrameworkInfo-&gt;'%(TargetPlatformMonikers)')</TargetPlatformMonikers>
189-
<AdditionalPropertiesFromProject>$(_AdditionalPropertiesFromProject)</AdditionalPropertiesFromProject>
190-
<HasSingleTargetFramework>false</HasSingleTargetFramework>
191-
<IsRidAgnostic>@(_TargetFrameworkInfo-&gt;'%(IsRidAgnostic)')</IsRidAgnostic>
192-
<!-- Extract necessary information for SetPlatform negotiation -->
193-
<!-- This target does not run for cpp projects. -->
194-
<IsVcxOrNativeProj>false</IsVcxOrNativeProj>
195-
<Platform Condition="$([MSBuild]::AreFeaturesEnabled('17.4'))">$(Platform)</Platform>
196-
<Platforms>$(Platforms)</Platforms>
197-
</_ThisProjectBuildMetadata>
198-
</ItemGroup>
199-
</Target>
200-
<Target Name="_ComputeTargetFrameworkItems" Returns="@(InnerOutput)">
201-
<ItemGroup>
202-
<_TargetFramework Include="$(TargetFrameworks)" />
203-
<!-- Make normalization explicit: Trim; Deduplicate by keeping first occurrence, case insensitive -->
204-
<_TargetFrameworkNormalized Include="@(_TargetFramework-&gt;Trim()-&gt;Distinct())" />
205-
<_InnerBuildProjects Include="$(MSBuildProjectFile)">
206-
<AdditionalProperties>TargetFramework=%(_TargetFrameworkNormalized.Identity)</AdditionalProperties>
207-
</_InnerBuildProjects>
208-
</ItemGroup>
209-
</Target>
210-
<Target Name="GetTargetFrameworksWithPlatformFromInnerBuilds" DependsOnTargets="_ComputeTargetFrameworkItems">
211-
<MSBuild Projects="@(_InnerBuildProjects)" Condition="'@(_InnerBuildProjects)' != '' " Targets="GetTargetFrameworksWithPlatformForSingleTargetFramework" BuildInParallel="$(BuildInParallel)">
212-
<Output ItemName="_TargetFrameworkInfo" TaskParameter="TargetOutputs" />
213-
</MSBuild>
214-
</Target>
215-
<!--
216-
Target that allows targets consuming source control confirmation to establish a dependency on targets producing this information.
217-
218-
Any target that reads SourceRevisionId, PrivateRepositoryUrl, SourceRoot, and other source control properties and items
219-
should depend on this target and be conditioned on '$(SourceControlInformationFeatureSupported)' == 'true'.
220-
221-
SourceRevisionId property uniquely identifies the source control revision of the repository the project belongs to.
222-
For Git repositories this id is a commit hash, for TFVC repositories it's the changeset number, etc.
223-
224-
PrivateRepositoryUrl property stores the URL of the repository supplied by the CI server or retrieved from source control manager.
225-
Targets consuming this property shall not publish its value implicitly as it might inadvertently reveal an internal URL.
226-
Instead, they shall only do so if the project sets PublishRepositoryUrl property to true. For example, the NuGet Pack target
227-
may include the repository URL in the nuspec file generated for NuGet package produced by the project if PublishRepositoryUrl is true.
228-
229-
SourceRoot item group lists all source roots that the project source files reside under and their mapping to source control server URLs,
230-
if available. This includes both source files under source control as well as source files in source packages. SourceRoot items are
231-
used by compilers to determine path map in deterministic build and by SourceLink provider, which maps local paths to URLs of source files
232-
stored on the source control server.
233-
234-
Source control information provider that sets these properties and items shall execute before this target (by including
235-
InitializeSourceControlInformation in its BeforeTargets) and set source control properties and items that haven't been initialized yet.
236-
-->
237-
<Target Name="InitializeSourceControlInformation" />
238-
<PropertyGroup>
239-
<SourceControlInformationFeatureSupported>true</SourceControlInformationFeatureSupported>
240-
</PropertyGroup>
241-
<!--
242-
============================================================
243-
DispatchToInnerBuilds
244-
245-
Builds this project with /t:$(InnerTarget) /p:TargetFramework=X for each
246-
value X in $(TargetFrameworks)
247-
248-
[IN]
249-
$(TargetFrameworks) - Semicolon delimited list of target frameworks.
250-
$(InnerTargets) - The targets to build for each target framework
251-
252-
[OUT]
253-
@(InnerOutput) - The combined output items of the inner targets across
254-
all target frameworks..
255-
============================================================
256-
-->
257-
<Target Name="DispatchToInnerBuilds" DependsOnTargets="_ComputeTargetFrameworkItems" Returns="@(InnerOutput)">
258-
<!-- If this logic is changed, also update Clean -->
259-
<MSBuild Projects="@(_InnerBuildProjects)" Condition="'@(_InnerBuildProjects)' != '' " Targets="$(InnerTargets)" BuildInParallel="$(BuildInParallel)">
260-
<Output ItemName="InnerOutput" TaskParameter="TargetOutputs" />
261-
</MSBuild>
262-
</Target>
263-
<!--
264-
============================================================
265-
Build
266-
267-
Cross-targeting version of Build.
268-
269-
[IN]
270-
$(TargetFrameworks) - Semicolon delimited list of target frameworks.
271-
272-
$(InnerTargets) - The targets to build for each target framework. Defaults
273-
to 'Build' if unset, but allows override to support
274-
`msbuild /p:InnerTargets=X;Y;Z` which will build X, Y,
275-
and Z targets for each target framework.
276-
277-
[OUT]
278-
@(InnerOutput) - The combined output items of the inner targets across
279-
all builds.
280-
============================================================
281-
-->
282-
<Target Name="Build" DependsOnTargets="_SetBuildInnerTarget;DispatchToInnerBuilds" />
283-
<Target Name="_SetBuildInnerTarget" Returns="@(InnerOutput)">
284-
<PropertyGroup Condition="'$(InnerTargets)' == ''">
285-
<InnerTargets>Build</InnerTargets>
286-
</PropertyGroup>
287-
</Target>
288-
<!--
289-
============================================================
290-
Clean
291-
292-
Cross-targeting version of clean.
293-
294-
Inner-build dispatch is a clone of DispatchToInnerBuilds;
295-
the only reason it's replicated is that it must be a different
296-
target to be run in the same build (e.g. by Rebuild or by
297-
a /t:Clean;Build invocation.
298-
============================================================
299-
-->
300-
<Target Name="Clean" DependsOnTargets="_ComputeTargetFrameworkItems">
301-
<!-- If this logic is changed, also update DispatchToInnerBuilds -->
302-
<MSBuild Projects="@(_InnerBuildProjects)" Condition="'@(_InnerBuildProjects)' != '' " Targets="Clean" BuildInParallel="$(BuildInParallel)" />
303-
</Target>
304-
<!--
305-
============================================================
306-
Rebuild
307-
308-
Cross-targeting version of rebuild.
309-
============================================================
310-
-->
311-
<Target Name="Rebuild" DependsOnTargets="Clean;Build" />
312-
<!--
313-
This will import NuGet restore targets. We need restore to work before any package assets are available.
314-
-->
315-
<PropertyGroup>
316-
<MSBuildUseVisualStudioDirectoryLayout Condition="'$(MSBuildUseVisualStudioDirectoryLayout)'==''">$([MSBuild]::IsRunningFromVisualStudio())</MSBuildUseVisualStudioDirectoryLayout>
317-
<NuGetRestoreTargets Condition="'$(NuGetRestoreTargets)'=='' and '$(MSBuildUseVisualStudioDirectoryLayout)'=='true'">$([MSBuild]::GetToolsDirectory32())\..\..\..\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets</NuGetRestoreTargets>
318-
<NuGetRestoreTargets Condition="'$(NuGetRestoreTargets)'==''">$(MSBuildToolsPath)\NuGet.targets</NuGetRestoreTargets>
319-
</PropertyGroup>
320-
<Import Project="$(NuGetRestoreTargets)" />
321-
<Import Project="$(CustomAfterMicrosoftCommonCrossTargetingTargets)" Condition="'$(CustomAfterMicrosoftCommonCrossTargetingTargets)' != '' and Exists('$(CustomAfterMicrosoftCommonCrossTargetingTargets)')" />
322-
<!--
323-
Allow extensions like NuGet restore to work before any package assets are available.
324-
-->
325-
<PropertyGroup>
326-
<ImportByWildcardAfterMicrosoftCommonCrossTargetingTargets Condition="'$(ImportByWildcardAfterMicrosoftCommonCrossTargetingTargets)' == ''">true</ImportByWildcardAfterMicrosoftCommonCrossTargetingTargets>
327-
</PropertyGroup>
328-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.CrossTargeting.targets\ImportAfter\*.targets" Condition="'$(ImportByWildcardAfterMicrosoftCommonCrossTargetingTargets)' == 'true' and exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.CrossTargeting.targets\ImportAfter')" />
329-
<!--
330-
Import project extensions which usually come from packages. Package management systems will create a file at:
331-
$(MSBuildProjectExtensionsPath)\$(MSBuildProjectFile).<SomethingUnique>.targets
332-
333-
Each package management system should use a unique moniker to avoid collisions. It is a wild-card iport so the package
334-
management system can write out multiple files but the order of the import is alphabetic because MSBuild sorts the list.
335-
336-
This is the same import that would happen in an inner (non-cross targeting) build. Package management systems are responsible for generating
337-
appropriate conditions based on $(IsCrossTargetingBuild) to pull in only those package targets that are meant to participate in a cross-targeting
338-
build.
339-
-->
340-
<PropertyGroup>
341-
<ImportProjectExtensionTargets Condition="'$(ImportProjectExtensionTargets)' == ''">true</ImportProjectExtensionTargets>
342-
</PropertyGroup>
343-
<Import Project="$(MSBuildProjectExtensionsPath)$(MSBuildProjectFile).*.targets" Condition="'$(ImportProjectExtensionTargets)' == 'true' and exists('$(MSBuildProjectExtensionsPath)')" />
344-
<PropertyGroup>
345-
<ImportDirectoryBuildTargets Condition="'$(ImportDirectoryBuildTargets)' == ''">true</ImportDirectoryBuildTargets>
346-
</PropertyGroup>
347-
<!--
348-
Determine the path to the directory build targets file if the user did not disable $(ImportDirectoryBuildTargets) and
349-
they did not already specify an absolute path to use via $(DirectoryBuildTargetsPath)
350-
-->
351-
<PropertyGroup Condition="'$(ImportDirectoryBuildTargets)' == 'true' and '$(DirectoryBuildTargetsPath)' == ''">
352-
<_DirectoryBuildTargetsFile Condition="'$(_DirectoryBuildTargetsFile)' == ''">Directory.Build.targets</_DirectoryBuildTargetsFile>
353-
<_DirectoryBuildTargetsBasePath Condition="'$(_DirectoryBuildTargetsBasePath)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), '$(_DirectoryBuildTargetsFile)'))</_DirectoryBuildTargetsBasePath>
354-
<DirectoryBuildTargetsPath Condition="'$(_DirectoryBuildTargetsBasePath)' != '' and '$(_DirectoryBuildTargetsFile)' != ''">$([System.IO.Path]::Combine('$(_DirectoryBuildTargetsBasePath)', '$(_DirectoryBuildTargetsFile)'))</DirectoryBuildTargetsPath>
355-
</PropertyGroup>
356-
<Import Project="$(DirectoryBuildTargetsPath)" Condition="'$(ImportDirectoryBuildTargets)' == 'true' and exists('$(DirectoryBuildTargetsPath)')" />
357-
<PropertyGroup>
358-
<UseMSBuildTestInfrastructure Condition="'$(UseMSBuildTestInfrastructure)' == ''">false</UseMSBuildTestInfrastructure>
359-
</PropertyGroup>
360-
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.Test.targets" Condition="'$(UseMSBuildTestInfrastructure)' == 'true'" />
361-
</Project>
362-
""";
363-
364-
private const string MicrosoftCommonTesttargets = """
365-
<Project>
366-
<Target Name="Test"></Target>
367-
</Project>
368137
""";
369138
}

0 commit comments

Comments
 (0)