MSBuild.Sdk.SqlProj icon indicating copy to clipboard operation
MSBuild.Sdk.SqlProj copied to clipboard

Feature request: Allow for specifying multiple SqlServerVersions on single project

Open sykesjd opened this issue 3 years ago • 6 comments

The .NET SDK csproj standard allows for specifying a multi-value TargetFrameworks property as an alternative to the single-value TargetFramework property, e.g.:

<PropertyGroup>
  <TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
</PropertyGroup>

With the above, building the project would produce DLLs for all three frameworks specified.

In the same vein, this sqlproj SDK standard should ideally allow for specifying a multi-value SqlServerVersions property as an alternative to the single-value SqlServerVersion property, e.g.:

<PropertyGroup>
  <TargetFramework>net6.0</TargetFramework>
  <SqlServerVersions>Sql130;SqlAzure</SqlServerVersions>
</PropertyGroup>

The above addition should allow for building the same sqlproj project against multiple SQL Server versions with one build command, which would as a result allow for deploying the same database schema to both an on-premise database and an Azure SQL database (as in the example above) without having to maintain two separate projects that are identical in every regard except for the SqlServerVersion.

sykesjd avatar Apr 07 '22 13:04 sykesjd

Thank you for your suggestions @sykesjd. I think this would be a great addition and I can see the value in it. If anyone is willing to implement this we would gladly take a PR for it. Not sure when I'll get around to implementing this myself.

jmezach avatar Apr 08 '22 06:04 jmezach

@sykesjd I have no issues with deployment to my localDb when SqlServerVersion is SqlAzure.

ErikEJ avatar Nov 22 '22 14:11 ErikEJ

@sykesjd I have no issues with deployment to my localDb when SqlServerVersion is SqlAzure.

No, but you can't deploy a dacpac targeting SqlAzure to an on-premise SQL Server instance - one of the teams where I work found that out the hard way.

sykesjd avatar Nov 22 '22 14:11 sykesjd

LocalDB is an "on-premise SQL Server instance" - which SQL version were being deployed to?

ErikEJ avatar Nov 22 '22 14:11 ErikEJ

LocalDB is an "on-premise SQL Server instance" - which SQL version were being deployed to?

If memory serves, it was a SQL Server 2016 instance.

To clarify, the scenario I mentioned dealt with an actual sqlproj project rather than one of these SDK projects.

sykesjd avatar Nov 22 '22 14:11 sykesjd

You can just use the /p:AllowIncompatiblePlatform=true option when publishing @jmezach FYI

ErikEJ avatar Nov 27 '22 18:11 ErikEJ