Azuredatastudio: Passing relative path to NETCoreTargetsPath doesn't work

Created on 29 Jul 2020  路  7Comments  路  Source: microsoft/azuredatastudio




  • Azure Data Studio Version:
    Passing a relative path to the NETCoreTargetsPath doesn't work as it either can't find the targets file or can't find the dlls. even though its the same folder

Steps to Reproduce:

  1. Passing a relative path to the NETCoreTargetsPath with "../../../src/lib/BuildDirectory" doesn't resolve the targets
    The imported project "C:\Users\SimonSabin\source\repos\src\lib\BuildDirectory\Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found. Confirm that
    the expression in the Import declaration "../../../src/lib/BuildDirectory\Microsoft.Data.Tools.Schema.SqlTasks.targets" is correct, and that the file exists on disk.

  2. Passing a relative path to the NETCoreTargetsPath with "../../src/lib/BuildDirectory" resolves the targets but not the tasks.dll
    The "SqlModelResolutionTask" task could not be loaded from the assembly C:\Users\SimonSabin\source\repos\template.sql\src\lib\BuildDirectory../.
    ./src/lib/BuildDirectory\Microsoft.Data.Tools.Schema.Tasks.Sql.dll. Could not load file or assembly 'C:\Users\SimonSabin\source\repos\template.sql\src\src\lib\BuildDirectory\Microsoft.Data.Tools.Schema.Tasks.Sql.dll'

Area - SQL Project Bug Needs More Info 1 Done

Most helpful comment

Sure just wanted this logged.

All 7 comments

  • @dzsquared FYI

Thanks @simonsabin - so far we have been concentrating on build from ADS scenarios. The commandline build would need few extra steps/configs. We will try to get the steps for commandline build documented and shared soon.

Sure just wanted this logged.

Hi @simonsabin, had a few quick questions while looking into this, can you please help with the following

  1. If you are using command line directly the paths are parsed by dotnet and not ADS so it seems like dotnet is not able to understand the paths in this case. Can you please check if giving windows style (backslash paths) work. I tried the repro giving windows sytle relative paths (on windows machine) and the build worked.

  2. This path "C:\Users\SimonSabin\source\repos\src\lib\BuildDirectory\Microsoft.Data.Tools.Schema.SqlTasks.targets" does not seem correct - as the build directory path should look like .azuredatastudio-insiders\extensions\microsoft.sql-database-projects-0.1.2\BuildDirectory. Are you copying the BuildDirectory folder to repos\src manually?

  3. The build from ADS metions the commandline used in output, can you please compare the command line with that and let us know if you are using any different params (other than the relative path in place of absolute paths). For eaxample you would need /p:NetCoreBuild=true and /p:NETCoreTargetsPath=""

Thanks again for the help!

Hi @simonsabin, just wanted to check back to see if the above mentioned options work for you. Thanks!

Will check this week

expected to be fixed

Found the problem. The sqltargets is loaded by referencing

$(NETCoreTargetsPath)\Microsoft.Data.Tools.Schema.SqlTasks.targets

the sql.dll is loaded by referencing
xml <UsingTask TaskName="SqlBuildTask" AssemblyFile="$(SqlServerRedistPath)\Microsoft.Data.Tools.Schema.Tasks.Sql.dll" />
the SqlServerRedistPath is always the same as NetCoreTargetsPath for NetCore builds
xml <PropertyGroup Condition=" $(NetCoreBuild) == true"> <DacPacRootPath>$(NETCoreTargetsPath)</DacPacRootPath> <!-- where all dacpacs are present --> <SqlServerRedistPath>$(NETCoreTargetsPath)</SqlServerRedistPath> <!-- where all dlls are present --> </PropertyGroup>

The issue is that the relative path for the dll, is relative to the location of the targets file and thus the compound path is effectively
$(solutionpath)\$(NETCoreTargetsPath)\$(NETCoreTargetsPath)

A solution is for the
xml <PropertyGroup Condition=" $(NetCoreBuild) == true"> <DacPacRootPath>.</DacPacRootPath> <!-- where all dacpacs are present --> <SqlServerRedistPath>.</SqlServerRedistPath> <!-- where all dlls are present --> </PropertyGroup>

Was this page helpful?
0 / 5 - 0 ratings