Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating Microsoft.Build.Sql for utilising in Visual Studio #443

Merged
merged 12 commits into from
May 31, 2024
22 changes: 16 additions & 6 deletions src/Microsoft.Build.Sql/sdk/Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,29 @@
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />

<PropertyGroup>
<NetCoreBuild Condition="'$(NetCoreBuild)' == '' And '$(MSBuildRuntimeType)' == 'Core'">true</NetCoreBuild>
<NetCoreBuild Condition="'$(NetCoreBuild)' == '' And '$(MSBuildRuntimeType)' == 'Full'">false</NetCoreBuild>
<NETCoreTargetsPath Condition="$(NETCoreTargetsPath) == ''">$(MSBuildThisFileDirectory)..\tools\netstandard2.1</NETCoreTargetsPath>
<TargetFramework Condition="'$(TargetFramework)' == '' AND '$(NetCoreBuild)' == 'true'">netstandard2.1</TargetFramework>
</PropertyGroup>

<!-- building in Visual Studio requires some sort of TargetFrameworkVersion. So we condition to NetCoreBuild as false to avoid failures -->
<PropertyGroup Condition="'$(NetCoreBuild)'=='false'">
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkMoniker>.NETFramework,Version=$(TargetFrameworkVersion)</TargetFrameworkMoniker>
</PropertyGroup>

<!-- Defaults from SSDT -->
<PropertyGroup>

<!-- Required -->
<Platforms Condition=" '$(Platforms)' == '' ">AnyCPU</Platforms>
<Configurations Condition=" '$(Configurations)' == '' ">Debug;Release</Configurations>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<PlatformName Condition="'$(PlatformName)' == ''">$(Platform)</PlatformName>
<OutputType>Database</OutputType>

<!-- Optional -->
Expand All @@ -26,16 +36,16 @@
</PropertyGroup>

<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">16.0</VisualStudioVersion>
<!-- Default to the v16.0 targets path if the targets file for the current VS version is not found -->
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">17.0</VisualStudioVersion>
<!-- Default to the v17.0 targets path if the targets file for the current VS version is not found -->
<SSDTExists Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets')">True</SSDTExists>
<VisualStudioVersion Condition="'$(SSDTExists)' == ''">16.0</VisualStudioVersion>
<VisualStudioVersion Condition="'$(SSDTExists)' == ''">17.0</VisualStudioVersion>
</PropertyGroup>

<ItemGroup>
<!-- Build default globbing pattern includes all sql files in all subfolders, excluding bin and obj -->
<Build Include="**/*.sql" />
<Build Remove="bin/**/*.sql" />
<Build Remove="obj/**/*.sql" />
</ItemGroup>
</Project>
</Project>
55 changes: 27 additions & 28 deletions src/Microsoft.Build.Sql/sdk/Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,28 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- Default build configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PropertyGroup>
<WarningLevel Condition=" '$(WarningLevel)' == '' ">4</WarningLevel>
<TreatWarningsAsErrors Condition=" '$(TreatWarningsAsErrors)' == '' ">false</TreatWarningsAsErrors>
<BuildScriptName Condition=" '$(BuildScriptName)' == '' ">$(MSBuildProjectName).sql</BuildScriptName>
<DefineTrace Condition=" '$(DefineTrace)' == '' ">true</DefineTrace>
<ErrorReport Condition=" '$(ErrorReport)' == '' ">prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath Condition=" '$(OutputPath)' == '' ">bin\Release\</OutputPath>
<DebugType Condition=" '$(DebugType)' == '' ">pdbonly</DebugType>
<Optimize Condition=" '$(Optimize)' == '' ">true</Optimize>
<DefineDebug Condition=" '$(DefineDebug)' == '' ">false</DefineDebug>
<DebugSymbols Condition=" '$(DebugSymbols)' == '' ">false</DebugSymbols>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath Condition=" '$(OutputPath)' == '' ">bin\Debug\</OutputPath>
<DebugType Condition=" '$(DebugType)' == '' ">full</DebugType>
<Optimize Condition=" '$(Optimize)' == '' ">false</Optimize>
<DefineDebug Condition=" '$(DefineDebug)' == '' ">true</DefineDebug>
<DebugSymbols Condition=" '$(DebugSymbols)' == '' ">true</DebugSymbols>
</PropertyGroup>

<!-- Pack target properties -->
<PropertyGroup>
<PackageType>$(PackageType);DACPAC</PackageType>
Expand All @@ -40,8 +38,13 @@
<NoWarn>$(NoWarn),NU5128</NoWarn>
</PropertyGroup>

<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />

<Target Name="CreateManifestResourceNames" />
<!-- CoreCompile is a target inside target Build on Microsoft.Common.targets that is not implemented there but allows us to personalize our compile/build flow, while
executing all the other targets inside Build regularly. We implement it before importing Common.targets because it's not implemented there, so it will not be
overriden when importing the targets.
-->
<Target Name="CoreCompile" />

<Import Condition="'$(NetCoreBuild)' == 'true'" Project="$(MSBuildThisFileDirectory)../tools/netstandard2.1/Microsoft.Data.Tools.Schema.SqlTasks.targets"/>
<Import Condition="'$(NetCoreBuild)' != 'true' AND '$(SQLDBExtensionsRefPath)' != ''" Project="$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.SqlTasks.targets" />
<Import Condition="'$(NetCoreBuild)' != 'true' AND '$(SQLDBExtensionsRefPath)' == ''" Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" />
Expand All @@ -62,10 +65,6 @@
<PackageReference Condition="'$(NetCoreBuild)' == 'true'" Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" IsImplicitlyDefined="true" />
</ItemGroup>

<ItemGroup>
<Folder Include="Properties" />
</ItemGroup>

<ItemGroup>
<!-- Remove files specified as PreDeploy, PostDeploy, and None scripts from build -->
<Build Remove="@(PreDeploy)" />
Expand Down