File tree Expand file tree Collapse file tree 5 files changed +73
-3
lines changed
src/Microsoft.Build.Sql/sdk
test/Microsoft.Build.Sql.Tests
BuildWithDefaultItemsDisabled
FailBuildOnDuplicatedItems Expand file tree Collapse file tree 5 files changed +73
-3
lines changed Original file line number Diff line number Diff line change 48
48
49
49
<ItemGroup >
50
50
<!-- Build default globbing pattern includes all sql files in all subfolders, excluding bin and obj -->
51
- <Build Include =" **/*.sql" />
52
- <Build Remove =" bin/**/*.sql" />
53
- <Build Remove =" obj/**/*.sql" />
51
+ <Build Condition =" '$(EnableDefaultSqlItems)' == 'true'" Include =" **/*.sql" Exclude =" $(DefaultSqlItemExcludes)" />
54
52
</ItemGroup >
55
53
</Project >
Original file line number Diff line number Diff line change 68
68
<Target Name =" _CheckForUnsupportedTargetFrameworkAndFeatureCombination" />
69
69
70
70
<UsingTask Condition =" '$(NetCoreBuild)' == 'true'" TaskName =" AllowEmptyTelemetry" AssemblyFile =" $(MicrosoftNETBuildTasksAssembly)" />
71
+ <UsingTask Condition =" '$(NetCoreBuild)' == 'true'" TaskName =" CheckForDuplicateItems" AssemblyFile =" $(MicrosoftNETBuildTasksAssembly)" />
72
+
73
+ <Target Name =" CheckForDuplicateSqlItems" BeforeTargets =" _SetupSqlBuildInputs" >
74
+
75
+ <PropertyGroup >
76
+ <DefaultItemsMoreInformationLink >https://aka.ms/upgrade-sqlproject</DefaultItemsMoreInformationLink >
77
+ </PropertyGroup >
78
+
79
+ <CheckForDuplicateItems
80
+ Items =" @(Build)"
81
+ ItemName =" Build"
82
+ DefaultItemsEnabled =" $(EnableDefaultSqlItems)"
83
+ DefaultItemsOfThisTypeEnabled =" $(EnableDefaultSqlItems)"
84
+ PropertyNameToDisableDefaultItems =" EnableDefaultSqlItems"
85
+ MoreInformationLink =" $(DefaultItemsMoreInformationLink)"
86
+ ContinueOnError =" $(ContinueOnError)" >
87
+ <Output TaskParameter =" DeduplicatedItems" ItemName =" DeduplicatedSqlItems" />
88
+ </CheckForDuplicateItems >
89
+
90
+ <!-- Currently do nothing with DeduplicatedItems. There are some design time logic in Microsoft.NET.Sdk.DefaultItems.Shared.targets that we can implement in the future. -->
91
+
92
+ </Target >
71
93
72
94
<!-- Add dacpac file BuiltProjectOutputGroupOutput, so that it will get included in the NuGet package by the Pack target -->
73
95
<Target Name =" AddDacpacToBuiltProjectOutputGroupOutput" BeforeTargets =" BuiltProjectOutputGroup" >
138
160
<ArtifactReference Include =" @(_ResolvedDacpacPackageReference->'%(HintPath)')" Condition =" Exists(%(_ResolvedDacpacPackageReference.HintPath))" />
139
161
</ItemGroup >
140
162
</Target >
163
+
164
+ <!-- Default properties to be evaluated last -->
165
+ <PropertyGroup >
166
+ <EnableDefaultSqlItems Condition =" '$(EnableDefaultSqlItems)' == '' " >true</EnableDefaultSqlItems >
167
+ <DefaultSqlItemExcludes >$(DefaultSqlItemExcludes);$(BaseOutputPath)/**;$(BaseIntermediateOutputPath)/**</DefaultSqlItemExcludes >
168
+ </PropertyGroup >
169
+
141
170
</Project >
Original file line number Diff line number Diff line change @@ -405,5 +405,38 @@ public void BuildWithExternalReference()
405
405
406
406
Directory . Delete ( tempFolder , true ) ;
407
407
}
408
+
409
+ [ Test ]
410
+ // https://github.com/microsoft/DacFx/issues/561
411
+ public void FailBuildOnDuplicatedItems ( )
412
+ {
413
+ // Add a file that should be included in the default globbing pattern already
414
+ this . AddBuildFiles ( "Table1.sql" ) ;
415
+
416
+ int exitCode = this . RunDotnetCommandOnProject ( "build" , out _ , out _ ) ;
417
+
418
+ // Verify failure
419
+ Assert . AreEqual ( 1 , exitCode , "Build is expected to fail." ) ;
420
+ }
421
+
422
+ [ Test ]
423
+ public void BuildWithDefaultItemsDisabled ( )
424
+ {
425
+ // Add a file that should be included in the default globbing pattern already
426
+ this . AddBuildFiles ( "Table1.sql" ) ;
427
+
428
+ // Disable default items
429
+ ProjectUtils . AddProperties ( this . GetProjectFilePath ( ) , new Dictionary < string , string > ( )
430
+ {
431
+ { "EnableDefaultSqlItems" , "False" }
432
+ } ) ;
433
+
434
+ int exitCode = this . RunDotnetCommandOnProject ( "build" , out _ , out string stdError ) ;
435
+
436
+ // Verify success
437
+ Assert . AreEqual ( 0 , exitCode , "Build failed with error " + stdError ) ;
438
+ Assert . AreEqual ( string . Empty , stdError ) ;
439
+ this . VerifyDacPackage ( ) ;
440
+ }
408
441
}
409
442
}
Original file line number Diff line number Diff line change
1
+ CREATE TABLE [dbo].[Table1]
2
+ (
3
+ c1 int NOT NULL PRIMARY KEY ,
4
+ c2 int NULL
5
+ )
Original file line number Diff line number Diff line change
1
+ CREATE TABLE [dbo].[Table1]
2
+ (
3
+ c1 int NOT NULL PRIMARY KEY ,
4
+ c2 int NULL
5
+ )
You can’t perform that action at this time.
0 commit comments