MSBuild.Sdk.SqlProj: ARM support is broken with Microsoft.SqlTools.ManagedBatchParser

I’m trying to upgrade from the old .NET Framework SQL Projects to your .NET Standard 2.1 SQL Projects. (Thanks for creating this!!!) However, I get the following error:

SQL80001: Incorrect syntax near ‘:’.

I read in other closed issues that I need to add a Remove entry for the PostDeploy.sql script to the proj file, however it seems like these issues were from before the Post-Deployment folder was introduced, which omits all of its scripts from the build by default. How do I correct this?

Here are the relevant parts of my project file:

<Project Sdk="MSBuild.Sdk.SqlProj/3.1.1">
    <PropertyGroup>
        <TargetFramework>netstandard2.1</TargetFramework>
        <SqlServerVersion>Sql150</SqlServerVersion>
        <RunSqlCodeAnalysis>True</RunSqlCodeAnalysis>
	<SuppressTSqlWarnings>SRD0047,SRN0007</SuppressTSqlWarnings>
	<TreatTSqlWarningsAsErrors>True</TreatTSqlWarningsAsErrors>
	<RunScriptsFromReferences>True</RunScriptsFromReferences>
    </PropertyGroup>

	<ItemGroup>
		<!--<Content Remove="Pre-Deployment\**\**\*.sql" />
		<Content Remove="Pre-Deployment\PreDeploy.sql" />-->
		<PreDeploy Include="Pre-Deployment\PreDeploy.sql" />
		<!--<Content Remove="Post-Deployment\**\**\*.sql" />
		<Content Remove="Pre-Deployment\PostDeploy.sql" />-->
		<PostDeploy Include="Post-Deployment\PostDeploy.sql" />
	</ItemGroup>
</Project>

PostDeploy.sql: (I also tried with putting the sql script path in double quotes, but then I get another build error: SQL80001: ‘“.\Post-Deployment\dbo\StaticData\AppSetting.sql”’ is not a recognized option.)

:r .\Post-Deployment\dbo\StaticData\AppSetting.sql

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 33 (5 by maintainers)

Most upvoted comments

I can confirm that everything builds and there are no ManagedBatchParser errors in 3.1.2. Thanks.

Yes, the dll exists at that location:

Image

Version 3.1.1 with .NET 9.0.200 (not preview) gives the same error:

Build started at 10:41 AM… 1>------ Build started: Project: Test, Configuration: Debug Any CPU ------ Restored C:\Mac\Home\Downloads\Test\Test\Test.csproj (in 413 ms). 1>Using target framework net9.0 to run DacpacTool 1>Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. 1> —> System.IO.FileNotFoundException: Could not load file or assembly ‘Microsoft.SqlTools.ManagedBatchParser, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null’. The system cannot find the file specified. 1>File name: ‘Microsoft.SqlTools.ManagedBatchParser, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null’ 1> at MSBuild.Sdk.SqlProj.DacpacTool.ScriptInspector.AddIncludedFiles(FileInfo file) 1> at MSBuild.Sdk.SqlProj.DacpacTool.ScriptInspector.AddPostDeploymentScript(FileInfo script) in /home/runner/work/MSBuild.Sdk.SqlProj/MSBuild.Sdk.SqlProj/src/DacpacTool/ScriptInspector.cs:line 26 1> at MSBuild.Sdk.SqlProj.DacpacTool.Program.InspectIncludes(InspectOptions options) in /home/runner/work/MSBuild.Sdk.SqlProj/MSBuild.Sdk.SqlProj/src/DacpacTool/Program.cs:line 236 1> at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor) 1> at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span1 copyOfArgs, BindingFlags invokeAttr) 1> --- End of inner exception stack trace --- 1> at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span1 copyOfArgs, BindingFlags invokeAttr) 1> at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) 1> at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) 1> at System.Delegate.DynamicInvokeImpl(Object[] args) 1> at System.CommandLine.NamingConventionBinder.ModelBindingCommandHandler.InvokeAsync(InvocationContext context) 1> at System.CommandLine.Parsing.ParseResultExtensions.InvokeAsync(ParseResult parseResult, IConsole console) 1> at MSBuild.Sdk.SqlProj.DacpacTool.Program.Main(String[] args) in /home/runner/work/MSBuild.Sdk.SqlProj/MSBuild.Sdk.SqlProj/src/DacpacTool/Program.cs:line 85 1> at MSBuild.Sdk.SqlProj.DacpacTool.Program.<Main>(String[] args) 1>C:\Users\justintoth.nuget\packages\msbuild.sdk.sqlproj\3.1.1\Sdk\Sdk.targets(173,5): error MSB3073: The command “…” exited with code -532462766. 1>Done building project “Test.csproj” – FAILED. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== ========== Build completed at 10:41 AM and took 02.574 seconds ==========

That is probably because you use a preview SDK. Use a global.json file to stay on a released SDK.version