rr-wfm / MSBuild.Sdk.SqlProj

An MSBuild SDK that provides similar functionality to SQL Server Data Tools (.sqlproj) projects
MIT License
379 stars 42 forks source link

Problem with CodeAnalysisRules when using ";" (semicolon) #531

Closed cagrin closed 3 months ago

cagrin commented 3 months ago

I've been trying to run some SQL Code Analysis at 2.7.0 version and I've found a problem with defining CodeAnalysisRules using ";" (semicolon). Apparently it fails to build on linux\macos machine, but it works on windows. I assume that it is related to the fact that ";" (semicolon) is a command separator in bash. Here is a part of output:

Analyzing package '/workspaces/.../Example/obj/Debug/netstandard2.0/Example.dacpac' Successfully analyzed package 'obj/Debug/netstandard2.0/Example.dacpac' /usr/bin/sh: 2: /tmp/MSBuildTempvscode/tmp63c87377fa93446488be8bc7aa3855d4.exec.cmd: -SqlServer.Rules.SRN0007: not found /home/vscode/.nuget/packages/msbuild.sdk.sqlproj/2.7.0/Sdk/Sdk.targets(244,5): error MSB3073: The command "dotnet "/home/vscode/.nuget/packages/msbuild.sdk.sqlproj/2.7.0/Sdk/../tools/net6.0/DacpacTool.dll" build -o "obj/Debug/netstandard2.0/Example.dacpac" -n "Example" -v "1.0.0" -sv SqlAzure -i "obj/Debug/netstandard2.0/Example.InputFiles.txt" -r "/home/vscode/.nuget/packages/microsoft.sqlserver.dacpacs.azure.master/160.0.0/tools/master.dacpac;dbl=master|dbv=|srv=;" -dp IncludeCompositeObjects=true -an -ar -SqlServer.Rules.SRP0005;-SqlServer.Rules.SRN0007" exited with code 127.

See the part where "/usr/bin/sh" is trying to find "-SqlServer.Rules.SRN0007" command...

The problem is only when using ";" (semicolon) in CodeAnalysisRules: <CodeAnalysisRules>-SqlServer.Rules.SRP0005;-SqlServer.Rules.SRN0007</CodeAnalysisRules>

I've figured it out, that there is a dirty fix to that problem (and it works even on windows). Just add extra "" (quotation): <CodeAnalysisRules>"-SqlServer.Rules.SRP0005;-SqlServer.Rules.SRN0007"</CodeAnalysisRules>

cagrin commented 3 months ago

Thank you 🙏