TeamCity SQL Project : Microsoft.Data.Tools.Schema.SqlTasks.targets was not found - sql-server

TeamCity
I have a TeamCity project with a .NET CLI (dotnet) build step for a Visual Studio Solution ( .sln ).
The solution includes a SQL Project ( .sqlproj ).
Running this build-step gives error :
[build] D:\TeamCity\buildAgent\work\e9ff385151b10e4c\Services\AccountCharacteristics\Database-RoundHouse-Deploy1\Database\Database.sqlproj(67,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\2.2.101\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Database.sqlproj
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">11.0</VisualStudioVersion>
<!-- Default to the v11.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)' == ''">11.0</VisualStudioVersion>
</PropertyGroup>
<Import Condition="'$(SQLDBExtensionsRefPath)' != ''" Project="$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.SqlTasks.targets" />
<Import Condition="'$(SQLDBExtensionsRefPath)' == ''" Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" />
So it appears that SQLDBExtensionsRefPath = C:\Program Files\dotnet\sdk\2.2.101\Microsoft\VisualStudio\v11.0\SSDT\
Apparently the .sqlproj defaults to 11.0 -- a very old version of Visual Studio.
How does SQLDBExtensionsRefPath get set ? How can I install/config the agent for the correct path ?
My agent has :
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VisualStudio\v16.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets
Also I notice that a NuGet package has been released :
https://www.nuget.org/packages/Microsoft.Data.Tools.Msbuild/
But it's not clear how to use it. It seems clear I need to reference the package in the VS .csproj. But then how to ensure that Visual Studio and Team City point to the Microsoft.Data.Tools.Schema.SqlTasks.targets in the package ( under the packages folder ) ?

Set it as an environment variable with
setx SQLDBExtensionsRefPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VisualStudio\v16.0\SSDT"
or by adding via the 'environment variables' in the Windows UI
See https://learn.microsoft.com/en-us/archive/blogs/ssdt/part-5-use-your-own-build-and-deployment-agent

Related

MSBuild cannot build from CLI. Invalid static invocation syntax

I am trying to compile a C VS project from PowerShell using msbuild. The command I'm using for now is:
msbuild .\my_solution.sln /t:Rebuild /p:Configuration=Release
But when I try to build I get the following error:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.props(31,5): error MSB4186: Invalid static method invocation syntax: "[Microsoft.Build.Utilities.ToolLocat
ionHelper]::FindRootFolderWhereAllFilesExist($(_VCTargetsPathFolders), $(_RelativeToolsetFiles))". Method 'Microsoft.Build.Utilities.ToolLocationHelper.FindRootFolderWhereAllFilesExist' not found. Static meth
od invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(`a`, `b`)).
I have already tried the following:
Run as admin
Repair Visual Studio
Full uninstall and reinstall of Visual Studio.
Other useful info:
I am using Visual Studio Community 2019.
My msbuild path is: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin
My VCTargetsPath is: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\
Worth noting that on the CLI command I haven't added the additional include directories nor the additional dependencies while in the UI version I have. Despite this, the error I am expecting is somewhat like unknown reference to <function>. I am trying to solve this first error before proceeding to link the required libraries, I don't believe this causes the problem but I'm mentioning it just in case.
The strange thing is that if I rebuild using the Visual Studio UI the project builds without any problem.
Despite this, I need to build from CLI so I would be really thankful if someone shares where the problem may be.
Check your MSBuild version, I've had the same problem time ago.
For example:
msbuild
Microsoft (R) Build Engine version 4.0.30319 for .NET Framework
In my case (now), the latest version is 16.9.0 (Downloaded from here)
Microsoft (R) Build Engine version 16.9.0+57a23d249 for .NET Framework
Check your Windows Path, when I got the problem, I got a Windows Path that contains an older version of MSBuild, checking the folder I saw "msbuild.exe". I Removed that entry and put the new one for my good msbuild.
%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin
Seen on this post
This works well in my side with your description. So your environment has some problems.
Try these:
1) close VS IDE, run Developer Command Prompt for VS2019 as Administrator
type:
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Build.Framework.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Build.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Build.Engine.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Build.Conversion.Core.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Build.Tasks.Core.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Build.Utilities.Core.dll"
After that, restart it to test again.
This is up to your wish:
If it does not help, please run C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\layout\InstallCleanup.exe to uninstall all VS2017 andVS2019 versions with their registration information, any data. This is like a strong, thorough uninstallation.
Then, reinstall the version.

Build failed with error MSB4226: The imported project | REACT NATIVE WINDOWS

Visual studio 2017 and i am installed all required build tools .but when i run react-native run-windows . It show error like below code
C:\native\myapp>react-native run-windows
Restoring NuGet packages
Building C:/native/myapp/windows/com.tet.windows.sln
Found MSBuild v15.0 at C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin
Building Solution: C:/native/myapp/windows/com.tet.windows.sln
Build configuration: Debug
Build platform: x86
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\native\myapp\windows\com.tet.windows\com.tet.windows.csproj(171,11): error MSB4226: The imported project "C:\Program
Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\WindowsXaml\v15.0\Microsoft.Windows.UI.Xaml.CSha
rp.targets" was not found. Also, tried to find "Microsoft\WindowsXaml\v15.0\Microsoft.Windows.UI.Xaml.CSharp.targets" i
n the fallback search path(s) for $(MSBuildExtensionsPath) - "C:\Program Files (x86)\MSBuild" . These search paths are
defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\msbuild.exe.Config". Confir
m that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Current.targets(1
08,3): error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\
VC\VCTargets\Platforms\Win32\Platform.targets" was not found. Confirm that the path in the <Import> declaration is corr
ect, and that the file exists on disk. [C:\native\myapp\node_modules\react-native-windows\Folly\Folly.vcxproj]
Build failed with message Error: Command failed: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" "C:/native/myapp/windows/com.tet.windows.sln" /clp:NoSummary;NoItemAndPropertyList;Verbosity=quiet /nologo /p:Configuration=Debug /p:Platform=x86 /p:AppxBundle=Never /p:PlatformToolset=v141 /p:VisualStudioVersion=15.0. Check your build configuration.
I have got similar issue due to starting using VS 2019. All it says is that go to this file:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\msbuild.exe.Config
open it and find what is in this node:
<projectImportSearchPaths>
<searchPaths os="windows">
Change the value to navigate exactly where your MSBuild is right now. In my case, the change was:
<projectImportSearchPaths>
<searchPaths os="windows">
<property name="MSBuildExtensionsPath" value="$(MSBuildProgramFiles32)\Microsoft Visual Studio\2019\Enterprise"/>
<property name="MSBuildExtensionsPath32" value="$(MSBuildProgramFiles32)\Microsoft Visual Studio\2019\Enterprise"/>
<property name="MSBuildExtensionsPath64" value="$(MSBuildProgramFiles32)\Microsoft Visual Studio\2019\Enterprise"/>
<property name="VSToolsPath" value="$(MSBuildProgramFiles32)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v$(VisualStudioVersion)"/>
</searchPaths>
</projectImportSearchPaths>
value: Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio
Hope it helps.

Cordova project and windows platform

I have a cordova project and I added windows platform but when I run the project I have this error:
MSBuild v4.0 is not supported, aborting.
Error: AppPackages doesn't exists
Try to set OS environment variable
VSINSTALLDIR = C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\
which points to your Visual Studio folder with MSBuild directory.
You have of install Microsoft Build Tools:
https://www.visualstudio.com/downloads/
Navigate to Other Tools and Frameworks
Download Build Tools for Visual Studio 2017
After, set OS environment variable VSINSTALLDIR = C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\ which points to your Visual Studio folder with MSBuild directory

SQL Server Data Tools: Error loading custom DeploymentPlanModifier: Required contributor with id could not be loaded

I need to intercept an SSDT build to modify the build script. I've followed the MSDN Deployment Plan Modifier tutorial, but when I attempt to build the database project, I get the following error:
Required contributor with id 'MyDeploymentContributor.SqlRestartableScriptContributor'
could not be loaded.
I am using Visual Studio 2012 (Version 11.0.61219.00 Update 5) and SSDT Version 11.1.50730.0.
I signed the assembly but did not specify a password.
I've followed several solutions I've found online to no avail, including the following:
Updating Visual Studio and SSDT;
Copying MyDeploymentContributor.dll and MyDeploymentContributor.pdb to the following locations:
C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\Extensions
C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120\Extensions
Capturing an event log for SSDT and DacFx (following Kevin Cunnane's instructions at https://social.msdn.microsoft.com/Forums/en-US/5c84ab8e-b50b-4ecd-86da-866ac3bb2248/known-issue-with-ssdt-extensibility-in-current-release?forum=ssdt). Here are the results from the DacFx log:
Core Services: SafeDirectoryCatalog: Assembly C:\Program Files
(x86)\Microsoft Visual Stusio 11.0\Common7\IDE\Extensions\Micrsoft\SQLDB\DAC\120\Extensions\MyDeploymentContributor.dll
added
Core Services: Extension Lookup: directory C:\Program Files
(x86)\Microsoft Visual Stusio 11.0\Common7\IDE\Extensions\Micrsoft\SQLDB\DAC\120\Extensions added to extension lookup path
Core Services: FilteringCompositionContainer: Looking up exports for
Microsoft.SqlServer.Dac.Deployment.DeploymentPlanExecutor
Core Services: FilteringCompositionContainer: Changed part creation policy
to NonShared
Core Services: FilteringCompositionContainer: Looking up exports for
Microsoft.SqlServer.Dac.Deployment.DeploymentPlanModifier
There were no ContributorLoader messages. From this log, the contributor seems to be loading correctly. The SSDT log didn't contain any events that mentioned the contributor.
There are no required contributor arguments, so the DeploymentContributor node in my .sqlproj file looks like this:
<PropertyGroup>
<DeploymentContributors>
$(DeploymentContributors); MyDeploymentContributor.SqlRestartableScriptContributor
</DeploymentContributors>
</PropertyGroup>
Any help is appreciated. Thanks!
Thanks to Ed Elliot ( https://the.agilesql.club/Blogs/Ed-Elliott/About ), I was able to resolve this issue in my case.
I followed Ed's suggestions and it worked. I created a folder like C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120\Extensions\[YourContributorName]\ and copied all the contents (including DLLs) from C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120 to there.
In the contributor project, I referenced the DLLs inside C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120\Extensions\[YourContributorName]\
Once the project was built successfully, I copied the contributor .dll and .pdb files to the following location:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120\Extensions\[YourContributorName]\
Before, I was referencing the DLLs from C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin.
Hope this would help someone.

Reporting services - custom library is not working after installing report on production Server

I created a report which uses custom library created by me. I've copied these libraries to the following folders:
c:\Program Files\Microsoft SQL
Server\MSSQL.3\Reporting
Services\ReportServer\bin\
c:\Program Files\Microsoft Visual
Studio
8\Common7\IDE\PrivateAssemblies\
Everything works fine when I run the report using on development environment using Visual Studio. When I install it on Production Server (where these dlls were also copied) the following error is returned:
Failed to load expression host assembly. Details: The type initializer for 'MyParserForReportingServices.MyParser' threw an exception. (rsErrorLoadingExprHostAssembly)
Can someone please help me?
add your dll to this folder too
C:\Program Files\Microsoft SQL
Server\MSSQL.3\Reporting
Services\ReportManager\Bin
I had the same issue, and copied the DLL to the ReportServer folder and worked!!
Weird because in the doc. the ReportManager is mentioned but ReportServer not.
Thanks Masoud!

Resources