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
21 changes: 16 additions & 5 deletions src/Microsoft.Build.Sql/sdk/Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@
<TargetFramework Condition="'$(TargetFramework)' == '' AND '$(NetCoreBuild)' == 'true'">netstandard2.1</TargetFramework>
</PropertyGroup>

<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
Ri7Sh marked this conversation as resolved.
Show resolved Hide resolved

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

<Platforms>AnyCPU</Platforms>
<Configurations>Debug;Release</Configurations>

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

<!-- Optional -->
Expand All @@ -26,10 +31,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>

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

<ItemGroup>
Expand All @@ -38,4 +49,4 @@
<Build Remove="bin/**/*.sql" />
<Build Remove="obj/**/*.sql" />
</ItemGroup>
</Project>
</Project>
56 changes: 28 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 @@ -39,9 +37,15 @@
<!-- Suppress NU5128 since SQL NuGet Packages have no target framework dependencies -->
<NoWarn>$(NoWarn),NU5128</NoWarn>
</PropertyGroup>

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

<PropertyGroup>
<CSharpDesignTimeTargetsPath Condition="'$(CSharpDesignTimeTargetsPath)'==''">$(MSBuildExtensionsPath)\Microsoft\VisualStudio\Managed\Microsoft.CSharp.DesignTime.targets</CSharpDesignTimeTargetsPath>
</PropertyGroup>

<Import Project="$(CSharpDesignTimeTargetsPath)" Condition="'$(CSharpDesignTimeTargetsPath)' != '' and Exists('$(CSharpDesignTimeTargetsPath)')" />
<Target Name="CoreCompile" />
Ri7Sh marked this conversation as resolved.
Show resolved Hide resolved
<Target Name="CreateManifestResourceNames" />

<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 +66,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
Loading