-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathMicrosoft.Build.Sql.Templates.csproj
98 lines (90 loc) · 4.73 KB
/
Microsoft.Build.Sql.Templates.csproj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<PackageType>Template</PackageType>
<PackageId>Microsoft.Build.Sql.Templates</PackageId>
<Title>Microsoft.Build.Sql templates</Title>
<Description>Templates for creating new Microsoft.Build.Sql projects.</Description>
<PackageTags>DacFx sqlproj</PackageTags>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<IncludeBuildOutput>false</IncludeBuildOutput>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<NoDefaultExcludes>true</NoDefaultExcludes>
<TemplateIntermediateOutputPath>$(BaseIntermediateOutputPath)\$(Configuration)\$(MSBuildThisFileName)</TemplateIntermediateOutputPath>
<!-- NU5128 warns about dependencies, template package has no dependencies. -->
<NoWarn>$(NoWarn);NU5128</NoWarn>
<NoDefaultExcludes>true</NoDefaultExcludes>
</PropertyGroup>
<ItemGroup>
<Compile Remove="**\*" />
</ItemGroup>
<ItemGroup>
<Content Include="$(EnlistmentRoot)/LICENSE.txt" PackagePath="/" Pack="true" />
<Content Include="README.md" PackagePath="/" Pack="true" />
<Content Include="$(TemplateIntermediateOutputPath)\**" PackagePath="content/" Pack="true" />
</ItemGroup>
<Target Name="CleanIntermediateFolder" AfterTargets="Clean">
<RemoveDir Directories="$(TemplateIntermediateOutputPath)" />
</Target>
<!-- This target copies SQLproj template files to intermediate output path, then sets the SDK version to the current assembly version -->
<Target Name="CopyTemplateFiles" BeforeTargets="GenerateNuspec;Build">
<PropertyGroup>
<SqlProjTemplateIntermediateOutputPath>$(TemplateIntermediateOutputPath)\sqlproject</SqlProjTemplateIntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<TemplateFiles Include="sqlproject/**" />
</ItemGroup>
<Copy SourceFiles="@(TemplateFiles)" DestinationFiles="$(SqlProjTemplateIntermediateOutputPath)/%(RecursiveDir)%(Filename)%(Extension)" />
<ReplaceFileText
InputFilename="$(SqlProjTemplateIntermediateOutputPath)/SqlProject1.sqlproj"
OutputFilename="$(SqlProjTemplateIntermediateOutputPath)/SqlProject1.sqlproj"
MatchExpression="###ASSEMBLY_VERSION###"
ReplacementText="$(PackageVersion)" />
<ItemGroup>
<Content Remove="$(SqlProjTemplateIntermediateOutputPath)\**" />
<Content Include="$(SqlProjTemplateIntermediateOutputPath)\**" PackagePath="content/sqlproject/" Pack="true" />
</ItemGroup>
</Target>
<!-- This target copies code analysis template files to intermediate output path, then sets the SDK version to the current assembly version -->
<Target Name="CopyTemplateFiles_CodeAnalysis" BeforeTargets="GenerateNuspec;Build">
<Message Text="Using DacFx version '$(DacFxPackageVersion)'" Importance="high" />
<PropertyGroup>
<CodeAnalysisTemplateIntermediateOutputPath>$(TemplateIntermediateOutputPath)\sqlcodeanalysis</CodeAnalysisTemplateIntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<TemplateFilesCodeAnalysis Include="sqlcodeanalysis/**" />
</ItemGroup>
<Copy SourceFiles="@(TemplateFilesCodeAnalysis)" DestinationFiles="$(CodeAnalysisTemplateIntermediateOutputPath)/%(RecursiveDir)%(Filename)%(Extension)" />
<ReplaceFileText
InputFilename="$(CodeAnalysisTemplateIntermediateOutputPath)/SqlCodeAnalysis1.csproj"
OutputFilename="$(CodeAnalysisTemplateIntermediateOutputPath)/SqlCodeAnalysis1.csproj"
MatchExpression="###DACFX_ASSEMBLY_VERSION###"
ReplacementText="$(DacFxPackageVersion)" />
<ItemGroup>
<Content Remove="$(CodeAnalysisTemplateIntermediateOutputPath)\**" />
<Content Include="$(CodeAnalysisTemplateIntermediateOutputPath)\**" PackagePath="content/sqlcodeanalysis/" Pack="true" />
</ItemGroup>
</Target>
<UsingTask TaskName="ReplaceFileText" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)/Microsoft.Build.Tasks.Core.dll" >
<ParameterGroup>
<InputFilename ParameterType="System.String" Required="true" />
<OutputFilename ParameterType="System.String" Required="true" />
<MatchExpression ParameterType="System.String" Required="true" />
<ReplacementText ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Text.RegularExpressions" />
<Code Type="Fragment" Language="cs">
<![CDATA[
File.WriteAllText(
OutputFilename,
Regex.Replace(File.ReadAllText(InputFilename), MatchExpression, ReplacementText)
);
]]>
</Code>
</Task>
</UsingTask>
</Project>