@@ -35,6 +35,14 @@ public async Task RunTests_With_VSTest(string multiTfm, BuildConfiguration build
3535 . PatchCodeWithReplace ( "$Extensions$" , string . Empty ) ,
3636 addPublicFeeds : true ) ;
3737
38+ File . WriteAllText ( Path . Combine ( generator . TargetAssetPath , "Directory.Packages.props" ) , """
39+ <Project>
40+ <PropertyGroup>
41+ <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
42+ </PropertyGroup>
43+ </Project>
44+ """ ) ;
45+
3846 var compilationResult = await DotnetCli . RunAsync ( $ "test -c { buildConfiguration } { generator . TargetAssetPath } ", _acceptanceFixture . NuGetGlobalPackagesFolder . Path ) ;
3947 Assert . AreEqual ( 0 , compilationResult . ExitCode ) ;
4048
@@ -63,6 +71,14 @@ public async Task RunTests_With_MSTestRunner_DotnetTest(string multiTfm, BuildCo
6371 . PatchCodeWithReplace ( "$Extensions$" , string . Empty ) ,
6472 addPublicFeeds : true ) ;
6573
74+ File . WriteAllText ( Path . Combine ( generator . TargetAssetPath , "Directory.Packages.props" ) , """
75+ <Project>
76+ <PropertyGroup>
77+ <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
78+ </PropertyGroup>
79+ </Project>
80+ """ ) ;
81+
6682 var compilationResult = await DotnetCli . RunAsync ( $ "test -c { buildConfiguration } { generator . TargetAssetPath } ", _acceptanceFixture . NuGetGlobalPackagesFolder . Path ) ;
6783 Assert . AreEqual ( 0 , compilationResult . ExitCode ) ;
6884
@@ -91,6 +107,47 @@ public async Task RunTests_With_MSTestRunner_Standalone(string multiTfm, BuildCo
91107 . PatchCodeWithReplace ( "$Extensions$" , string . Empty ) ,
92108 addPublicFeeds : true ) ;
93109
110+ File . WriteAllText ( Path . Combine ( generator . TargetAssetPath , "Directory.Packages.props" ) , """
111+ <Project>
112+ <PropertyGroup>
113+ <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
114+ </PropertyGroup>
115+ </Project>
116+ """ ) ;
117+
118+ var compilationResult = await DotnetCli . RunAsync ( $ "build -c { buildConfiguration } { generator . TargetAssetPath } ", _acceptanceFixture . NuGetGlobalPackagesFolder . Path ) ;
119+ Assert . AreEqual ( 0 , compilationResult . ExitCode ) ;
120+ foreach ( var tfm in multiTfm . Split ( ";" ) )
121+ {
122+ var testHost = TestHost . LocateFrom ( generator . TargetAssetPath , AssetName , tfm , buildConfiguration : buildConfiguration ) ;
123+ var testHostResult = await testHost . ExecuteAsync ( ) ;
124+ testHostResult . AssertOutputContains ( "Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1" ) ;
125+ }
126+ }
127+
128+ [ ArgumentsProvider ( nameof ( GetBuildMatrixMultiTfmFoldedBuildConfiguration ) ) ]
129+ public async Task RunTests_With_CentralPackageManagement_Standalone ( string multiTfm , BuildConfiguration buildConfiguration )
130+ {
131+ using TestAsset generator = await TestAsset . GenerateAssetAsync (
132+ AssetName ,
133+ SourceCode
134+ . PatchCodeWithReplace ( "$MSTestVersion$" , MSTestVersion )
135+ . PatchCodeWithReplace ( "$OutputType$" , string . Empty )
136+ . PatchCodeWithReplace ( "$TargetFramework$" , $ "<TargetFrameworks>{ multiTfm } </TargetFrameworks>")
137+ . PatchCodeWithReplace ( "$EnableMSTestRunner$" , string . Empty )
138+ . PatchCodeWithReplace ( "$TestingPlatformDotnetTestSupport$" , string . Empty )
139+ . PatchCodeWithReplace ( "$ExtraProperties$" , string . Empty )
140+ . PatchCodeWithReplace ( "$Extensions$" , string . Empty ) ,
141+ addPublicFeeds : true ) ;
142+
143+ File . WriteAllText ( Path . Combine ( generator . TargetAssetPath , "Directory.Packages.props" ) , """
144+ <Project>
145+ <PropertyGroup>
146+ <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
147+ </PropertyGroup>
148+ </Project>
149+ """ ) ;
150+
94151 var compilationResult = await DotnetCli . RunAsync ( $ "build -c { buildConfiguration } { generator . TargetAssetPath } ", _acceptanceFixture . NuGetGlobalPackagesFolder . Path ) ;
95152 Assert . AreEqual ( 0 , compilationResult . ExitCode ) ;
96153 foreach ( var tfm in multiTfm . Split ( ";" ) )
@@ -160,6 +217,14 @@ public async Task RunTests_With_MSTestRunner_Standalone_Selectively_Enabled_Exte
160217 . PatchCodeWithReplace ( "$Extensions$" , msbuildExtensionEnableFragment ) ,
161218 addPublicFeeds : true ) ;
162219
220+ File . WriteAllText ( Path . Combine ( generator . TargetAssetPath , "Directory.Packages.props" ) , """
221+ <Project>
222+ <PropertyGroup>
223+ <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
224+ </PropertyGroup>
225+ </Project>
226+ """ ) ;
227+
163228 var compilationResult = await DotnetCli . RunAsync ( $ "build -c { buildConfiguration } { generator . TargetAssetPath } ", _acceptanceFixture . NuGetGlobalPackagesFolder . Path ) ;
164229 Assert . AreEqual ( 0 , compilationResult . ExitCode ) ;
165230 foreach ( var tfm in multiTfm . Split ( ";" ) )
@@ -188,6 +253,14 @@ public async Task RunTests_With_MSTestRunner_Standalone_EnableAll_Extensions(str
188253 . PatchCodeWithReplace ( "$Extensions$" , "<TestingExtensionsProfile>AllMicrosoft</TestingExtensionsProfile>" ) ,
189254 addPublicFeeds : true ) ;
190255
256+ File . WriteAllText ( Path . Combine ( generator . TargetAssetPath , "Directory.Packages.props" ) , """
257+ <Project>
258+ <PropertyGroup>
259+ <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
260+ </PropertyGroup>
261+ </Project>
262+ """ ) ;
263+
191264 var compilationResult = await DotnetCli . RunAsync ( $ "build -c { buildConfiguration } { generator . TargetAssetPath } ", _acceptanceFixture . NuGetGlobalPackagesFolder . Path ) ;
192265 Assert . AreEqual ( 0 , compilationResult . ExitCode ) ;
193266 foreach ( var tfm in multiTfm . Split ( ";" ) )
@@ -227,6 +300,14 @@ public async Task RunTests_With_MSTestRunner_Standalone_Enable_Default_Extension
227300 . PatchCodeWithReplace ( "$Extensions$" , enableDefaultExtensions ? string . Empty : "<TestingExtensionsProfile>None</TestingExtensionsProfile>" ) ,
228301 addPublicFeeds : true ) ;
229302
303+ File . WriteAllText ( Path . Combine ( generator . TargetAssetPath , "Directory.Packages.props" ) , """
304+ <Project>
305+ <PropertyGroup>
306+ <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
307+ </PropertyGroup>
308+ </Project>
309+ """ ) ;
310+
230311 var compilationResult = await DotnetCli . RunAsync ( $ "build -c { buildConfiguration } { generator . TargetAssetPath } ", _acceptanceFixture . NuGetGlobalPackagesFolder . Path ) ;
231312 Assert . AreEqual ( 0 , compilationResult . ExitCode ) ;
232313 foreach ( var tfm in multiTfm . Split ( ";" ) )
@@ -259,6 +340,14 @@ public async Task Invalid_TestingProfile_Name_Should_Fail(string multiTfm, Build
259340 . PatchCodeWithReplace ( "$Extensions$" , "<TestingExtensionsProfile>WrongName</TestingExtensionsProfile>" ) ,
260341 addPublicFeeds : true ) ;
261342
343+ File . WriteAllText ( Path . Combine ( generator . TargetAssetPath , "Directory.Packages.props" ) , """
344+ <Project>
345+ <PropertyGroup>
346+ <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
347+ </PropertyGroup>
348+ </Project>
349+ """ ) ;
350+
262351 var compilationResult = await DotnetCli . RunAsync ( $ "build -c { buildConfiguration } { generator . TargetAssetPath } ", _acceptanceFixture . NuGetGlobalPackagesFolder . Path , failIfReturnValueIsNotZero : false ) ;
263352 Assert . AreEqual ( 1 , compilationResult . ExitCode ) ;
264353 compilationResult . AssertOutputContains ( "Invalid value for property TestingExtensionsProfile. Valid values are 'Default', 'AllMicrosoft' and 'None'." ) ;
@@ -291,6 +380,14 @@ await RetryHelper.RetryAsync(
291380 . PatchCodeWithReplace ( "$Extensions$" , string . Empty ) ,
292381 addPublicFeeds : true ) ;
293382
383+ File . WriteAllText ( Path . Combine ( generator . TargetAssetPath , "Directory.Packages.props" ) , """
384+ <Project>
385+ <PropertyGroup>
386+ <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
387+ </PropertyGroup>
388+ </Project>
389+ """ ) ;
390+
294391 var compilationResult = await DotnetCli . RunAsync ( $ "publish -r { RID } { generator . TargetAssetPath } ", _acceptanceFixture . NuGetGlobalPackagesFolder . Path ) ;
295392 compilationResult . AssertOutputNotContains ( "warning" ) ;
296393 compilationResult . AssertOutputContains ( "Generating native code" ) ;
@@ -311,6 +408,7 @@ await RetryHelper.RetryAsync(
311408 $TestingPlatformDotnetTestSupport$
312409 $ExtraProperties$
313410 <PlatformTarget>x64</PlatformTarget>
411+ <NoWarn>$(NoWarn);NU1507</NoWarn>
314412 </PropertyGroup>
315413
316414 <!-- Extensions -->
0 commit comments