Reputation: 21
I am attempting to run a build in TFS 2018. We also have SQL Server 2016 installed on the TFS build server (which is Windows Server 2016). Visual Studio is 2017. The first solution file produces the following error, and I have no idea from where this file is referenced:
2019-01-22T20:35:26.8607312Z Package:
2019-01-22T20:35:26.8608029Z Invoking Web Deploy to generate the package with the following settings:
2019-01-22T20:35:26.8608667Z $(LocalIisVersion) is 10
2019-01-22T20:35:26.8609527Z $(DestinationIisVersion) is 10
2019-01-22T20:35:26.8610846Z $(UseIis) is True
2019-01-22T20:35:26.8612479Z $(IisUrl) is http://localhost:62327/
2019-01-22T20:35:26.8614266Z $(IncludeIisSettings) is False
2019-01-22T20:35:26.8615630Z $(_DeploymentUseIis) is False
2019-01-22T20:35:26.8617245Z $(DestinationUseIis) is False
2019-01-22T20:35:26.8666548Z GenerateMsdeployManifestFiles:
2019-01-22T20:35:26.8684620Z Generate source manifest file for Web Deploy package/publish ...
2019-01-22T20:35:27.0589951Z Visual Studio is 2017. ##[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\Web\Deploy\Microsoft.Web.Publishing.MSDeploy.Common.targets(119,5): Error MSB4018: The "SqlScriptPreprocessSqlVariables" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.SqlServer.BatchParser, Version=13.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.SqlServer.BatchParser, Version=13.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'
at Microsoft.Web.Publishing.Tasks.SqlScriptPreprocessor.SqlScriptPreprocessSqlVariables.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Upvotes: 2
Views: 9865
Reputation: 295
Found a workaround here, for the desktop build. Did not try the TFS team build.
Use gacutil to register Microsoft.SqlServer.BatchParser v2015.130.1601.5 installed with Visual Studio 2017, apparently satisfying build task SqlScriptPreprocessSqlVariables even if it requested v13.100.0.0.
In:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\Microsoft\SQLCommon\130
or similar issue:
"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools\gacutil.exe" /i Microsoft.SqlServer.BatchParser.dll
or similar.
2023-02-14 The issue occurred again, now using Visual Studio 2022. The following workaround fixed the issue.
VS2022 now runs in 64 bit. Microsoft.SqlServer.BatchParser.dll built for 64 bit should be used. Also adding assemblies to the GAC is now discouraged. Instead copy the assembly from the installation location of VS2022, for example:
C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\Extensions\Microsoft\SQLCommon\150
to the correct MSBuild folder. Several MSBuild folders may be around, use the 64 bit folder actually used by VS2022, for example:
C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64
Build task SqlScriptPreprocessor.SqlScriptPreprocessSqlVariables resides in assembly Microsoft.Web.Publishing.Tasks.dll. That assembly asks for version 13.100.0.0 of Microsoft.SqlServer.BatchParser.dll. Version 13.100.0.0 cannot be used; it results in "Invalid assembly platform or ContentType in file". Instead add an assembly redirect for MSBuild. In for example:
C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\MSBuild.exe.config
add
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.BatchParser" culture="neutral" publicKeyToken="89845dcd8080cc91" />
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="15.100.0.0" />
</dependentAssembly>
15.100.0.0 being the assembly version of Microsoft.SqlServer.BatchParser.dll; ignore any file version such as 2018.150.1000.16.
Upvotes: 0
Reputation: 2723
Found the same workaround that Michiel referred to.
My situation:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\Microsoft\SQLCommon\130
. There is no similar path under C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools
My solution:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\BinMSBuild.exe.config
- see below)<!-- Workaround for errorMSB4018: The "SqlScriptPreprocessSqlVariables" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.SqlServer.BatchParser, Version=13.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified. -->
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.BatchParser" culture="neutral" publicKeyToken="89845dcd8080cc91" />
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="13.0.0.0"/>
</dependentAssembly>
Upvotes: 1