Steps to Reproduce:
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.
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'
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
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.
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
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>
Most helpful comment
Sure just wanted this logged.