@@ -121,7 +121,7 @@ public void Referencing_Cake_Core_with_PrivateAssets_results_in_no_error()
121
121
{
122
122
// given
123
123
fixture . WithoutDefaultCakeReference ( ) ;
124
- fixture . WithPackageReference ( "Cake.Core" , "0.38.5" , "all" ) ;
124
+ fixture . WithPackageReference ( "Cake.Core" , fixture . DefaultCakeVersion , "all" ) ;
125
125
126
126
// when
127
127
var result = fixture . Run ( ) ;
@@ -136,7 +136,7 @@ public void Referencing_Cake_Core_without_PrivateAssets_results_in_CCG0004_error
136
136
{
137
137
// given
138
138
fixture . WithoutDefaultCakeReference ( ) ;
139
- fixture . WithPackageReference ( "Cake.Core" , "0.38.5" ) ;
139
+ fixture . WithPackageReference ( "Cake.Core" , fixture . DefaultCakeVersion ) ;
140
140
141
141
// when
142
142
var result = fixture . Run ( ) ;
@@ -221,22 +221,27 @@ public void Missing_Required_Target_results_in_CCG0007_error()
221
221
// then
222
222
result . IsErrorExitCode . ShouldBeTrue ( ) ;
223
223
result . ErrorLines . ShouldContain ( l => l . IndexOf ( "CCG0007" , StringComparison . Ordinal ) > - 1 ) ;
224
- result . ErrorLines . ShouldContain ( l => l . IndexOf ( "netstandard2.0" , StringComparison . Ordinal ) > - 1 ) ;
224
+ result . ErrorLines . ShouldContain ( l => l . IndexOf ( fixture . DefaultTargetFrameworkForModules , StringComparison . Ordinal ) > - 1 ) ;
225
225
}
226
226
227
227
[ Fact ]
228
228
public void Missing_Suggested_Target_results_in_CCG0007_warning ( )
229
229
{
230
+ var missingTfm = fixture . DefaultTargetFrameworksForAddins
231
+ . Split ( ";" , StringSplitOptions . RemoveEmptyEntries )
232
+ . First ( ) ;
233
+ var allTfmButMissing = fixture . DefaultTargetFrameworksForAddins . Replace ( missingTfm , string . Empty ) ;
234
+
230
235
// given
231
- fixture . WithTargetFrameworks ( "netstandard2.0" ) ;
236
+ fixture . WithTargetFrameworks ( allTfmButMissing ) ;
232
237
233
238
// when
234
239
var result = fixture . Run ( ) ;
235
240
236
241
// then
237
- result . IsErrorExitCode . ShouldBeFalse ( ) ;
238
- result . WarningLines . ShouldContain ( l => l . IndexOf ( "CCG0007" , StringComparison . Ordinal ) > - 1 ) ;
239
- result . WarningLines . ShouldContain ( l => l . IndexOf ( "net461" , StringComparison . Ordinal ) > - 1 ) ;
242
+ result . IsErrorExitCode . ShouldBeTrue ( ) ;
243
+ result . ErrorLines . ShouldContain ( l => l . IndexOf ( "CCG0007" , StringComparison . Ordinal ) > - 1 ) ;
244
+ result . ErrorLines . ShouldContain ( l => l . IndexOf ( missingTfm , StringComparison . Ordinal ) > - 1 ) ;
240
245
}
241
246
242
247
[ Fact ]
@@ -246,6 +251,7 @@ public void Missing_Suggested_Target_net5_for_Cake_v100_results_in_CCG0007_warni
246
251
fixture . WithoutDefaultCakeReference ( ) ;
247
252
fixture . WithPackageReference ( "Cake.Core" , "1.0.0" , "all" ) ;
248
253
fixture . WithTargetFrameworks ( "netstandard2.0;net461" ) ;
254
+ fixture . OmitRecommendedCakeVersion ( ) ;
249
255
250
256
// when
251
257
var result = fixture . Run ( ) ;
@@ -351,7 +357,7 @@ public void ProjectType_When_Assembly_Is_Module_Is_Module()
351
357
{
352
358
// given
353
359
fixture . WithAssemblyName ( "Cake.Buildsystems.Module" ) ;
354
- fixture . WithTargetFrameworks ( "netstandard2.0" ) ;
360
+ fixture . WithTargetFrameworks ( fixture . DefaultTargetFrameworkForModules ) ;
355
361
fixture . WithCustomContent ( @"
356
362
<Target Name=""ForTest""
357
363
AfterTargets=""BeforeBuild""
@@ -376,7 +382,7 @@ public void ProjectType_When_Assembly_Is_Module_Is_Module()
376
382
public void ProjectType_When_PackageId_Is_Module_Is_Module ( )
377
383
{
378
384
// given
379
- fixture . WithTargetFrameworks ( "netstandard2.0" ) ;
385
+ fixture . WithTargetFrameworks ( fixture . DefaultTargetFrameworkForModules ) ;
380
386
fixture . WithCustomContent ( @"
381
387
<PropertyGroup>
382
388
<PackageId>Cake.Buildsystems.Module</PackageId>
@@ -498,7 +504,7 @@ public void Packaging_Different_Types_Should_Add_The_Correct_Icon(string assembl
498
504
fixture . WithAssemblyName ( assemblyName ) ;
499
505
if ( isModule )
500
506
{
501
- fixture . WithTargetFrameworks ( "netstandard2.0" ) ;
507
+ fixture . WithTargetFrameworks ( fixture . DefaultTargetFrameworkForModules ) ;
502
508
}
503
509
fixture . WithCustomContent ( @"
504
510
<PropertyGroup>
@@ -537,7 +543,7 @@ public void Packaging_Different_Types_Should_Add_The_Correct_IconUrl_To_Properti
537
543
fixture . WithAssemblyName ( assemblyName ) ;
538
544
if ( isModule )
539
545
{
540
- fixture . WithTargetFrameworks ( "netstandard2.0" ) ;
546
+ fixture . WithTargetFrameworks ( fixture . DefaultTargetFrameworkForModules ) ;
541
547
}
542
548
fixture . WithCustomContent ( @"
543
549
<PropertyGroup>
@@ -589,7 +595,7 @@ public void Missing_Module_Tag_Should_Raise_CCG0008_For_Modules()
589
595
<PackageId>Cake.Buildsystems.Module</PackageId>
590
596
</PropertyGroup>" ) ;
591
597
fixture . WithTags ( "cake build cake-build script" ) ;
592
- fixture . WithTargetFrameworks ( "netstandard2.0" ) ;
598
+ fixture . WithTargetFrameworks ( fixture . DefaultTargetFrameworkForModules ) ;
593
599
594
600
// when
595
601
var result = fixture . Run ( ) ;
@@ -651,6 +657,7 @@ public void Incorrect_Cake_Reference_Should_Raise_CCG0009()
651
657
// given
652
658
fixture . WithoutDefaultCakeReference ( ) ;
653
659
fixture . WithPackageReference ( "cake.core" , "0.38.5" , "All" ) ;
660
+ fixture . WithTargetFrameworks ( "netstandard2.0;net461;net5.0" ) ;
654
661
655
662
// when
656
663
var result = fixture . Run ( ) ;
@@ -667,6 +674,7 @@ public void Incorrect_But_Omitted_Cake_Reference_Should_Not_Raise_CCG0009()
667
674
// given
668
675
fixture . WithoutDefaultCakeReference ( ) ;
669
676
fixture . WithPackageReference ( "cake.core" , "0.38.5" , "All" ) ;
677
+ fixture . WithTargetFrameworks ( "netstandard2.0;net461;net5.0" ) ;
670
678
fixture . WithCustomContent ( @"
671
679
<ItemGroup>
672
680
<CakeContribGuidelinesOmitRecommendedCakeVersion Include=""Cake.Core"" />
@@ -680,29 +688,11 @@ public void Incorrect_But_Omitted_Cake_Reference_Should_Not_Raise_CCG0009()
680
688
result . WarningLines . ShouldBeEmpty ( ) ;
681
689
}
682
690
683
- [ Fact ]
684
- public void Missing_Suggested_Target_results_not_in_CCG0007_warning_if_NoWarn_is_set ( )
685
- {
686
- // given
687
- fixture . WithTargetFrameworks ( "netstandard2.0" ) ;
688
- fixture . WithCustomContent ( @"
689
- <PropertyGroup>
690
- <NoWarn>1701;1702;ccg0007</NoWarn>
691
- </PropertyGroup>" ) ;
692
-
693
- // when
694
- var result = fixture . Run ( ) ;
695
-
696
- // then
697
- result . IsErrorExitCode . ShouldBeFalse ( ) ;
698
- result . WarningLines . ShouldNotContain ( l => l . IndexOf ( "CCG0007" , StringComparison . Ordinal ) > - 1 ) ;
699
- }
700
-
701
691
[ Fact ]
702
692
public void Missing_Suggested_Target_results_in_CCG0007_error_if_WarningsAsErrors_is_set ( )
703
693
{
704
694
// given
705
- fixture . WithTargetFrameworks ( "netstandard2.0" ) ;
695
+ fixture . WithTargetFrameworks ( fixture . DefaultTargetFrameworkForModules ) ;
706
696
fixture . WithCustomContent ( @"
707
697
<PropertyGroup>
708
698
<WarningsAsErrors>NU1605;ccg0007</WarningsAsErrors >
@@ -738,5 +728,21 @@ public void Missing_Required_Target_results_in_CCG0007_error_if_Cake_Version_Is_
738
728
err . ShouldNotBeNull ( ) ;
739
729
err . ShouldContain ( "netstandard2.0" ) ;
740
730
}
731
+
732
+ [ Fact ]
733
+ public void Central_Package_Management_Correct_Cake_Reference_Should_Not_Raise_CCG0009 ( )
734
+ {
735
+ // given
736
+ fixture . WithoutDefaultCakeReference ( ) ;
737
+ fixture . WithPackageReference ( "cake.core" , privateAssets : "All" ) ;
738
+ fixture . WithCpmPackageVersion ( "Cake.Core" , fixture . DefaultCakeVersion ) ;
739
+
740
+ // when
741
+ var result = fixture . Run ( ) ;
742
+
743
+ // then
744
+ result . IsErrorExitCode . ShouldBeFalse ( ) ;
745
+ result . WarningLines . ShouldBeEmpty ( ) ;
746
+ }
741
747
}
742
748
}
0 commit comments