forked from microsoft/DacFx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMicrosoft.Build.Sql.Templates.csproj
71 lines (65 loc) · 3.11 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
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</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>
<IncludeBuildOutput>false</IncludeBuildOutput>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<NoDefaultExcludes>true</NoDefaultExcludes>
<TemplateIntermediateOutputPath>$(BaseIntermediateOutputPath)\$(Configuration)\$(MSBuildThisFileName)\sqlproject</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="$(TemplateIntermediateOutputPath)\**" PackagePath="content/" Pack="true" />
</ItemGroup>
<Target Name="CleanIntermediateFolder" AfterTargets="Clean">
<RemoveDir Directories="$(TemplateIntermediateOutputPath)" />
</Target>
<!-- This target copies template files to intermediate output path, then sets the SDK version to the current assembly version -->
<Target Name="CopyTemplateFiles" BeforeTargets="GenerateNuspec;Build">
<ItemGroup>
<TemplateFiles Include="sqlproject/**" />
</ItemGroup>
<Copy SourceFiles="@(TemplateFiles)" DestinationFiles="$(TemplateIntermediateOutputPath)/%(RecursiveDir)%(Filename)%(Extension)" />
<ReplaceFileText
InputFilename="$(TemplateIntermediateOutputPath)/SqlProject1.sqlproj"
OutputFilename="$(TemplateIntermediateOutputPath)/SqlProject1.sqlproj"
MatchExpression="###ASSEMBLY_VERSION###"
ReplacementText="$(PackageVersion)" />
<ItemGroup>
<Content Remove="$(TemplateIntermediateOutputPath)\**" />
<Content Include="$(TemplateIntermediateOutputPath)\**" PackagePath="content/" 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>