MSBuild.Sdk.SqlProj
MSBuild.Sdk.SqlProj copied to clipboard
net5.0 ref folder
Not a bug, but a comment:
It seems that when you specify framework net 5.0 the build process fails with this error
The "CopyRefAssembly" task was not given a value for the required parameter "SourcePath".
The solution is to add this line to <PropertyGroup>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
@verquepasa Thank you for reporting. To be honest, I'm not entirely what you mean. Would you mind sharing the contents of your project file and the full output of dotnet build so that we can have a look at what's going on? Perhaps we should be adding <ProduceReferenceAssembly>false</ProduceReferenceAssembly> to this SDK by default, but I'd like to understand it a little bit more before we do that.
Thanks for the answer. It seems that starting with net5.0 a new directory is created in the output folder
here is my (fixed) project file
<Project Sdk="MSBuild.Sdk.SqlProj/1.16.0">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<SqlServerVersion>Sql140</SqlServerVersion>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
</PropertyGroup>
<PropertyGroup>
<!-- Refer to https://github.com/rr-wfm/MSBuild.Sdk.SqlProj#publishing-support for supported publishing options -->
</PropertyGroup>
<ItemGroup>
<PackageReference Include="master" Version="1.0.0" />
<PackageReference Include="msdb" Version="1.0.0" />
</ItemGroup>
</Project>
if I don't put the ProduceReferenceAssembly=false line, I get this
Determining projects to restore...
All projects are up-to-date for restore.
Using package name MESF.Core.Database and version 1.0.1
Using SQL Server version Sql140
Adding reference to C:\x\.nuget\packages\master\1.0.0/tools/master.dacpac with external parts dbl=|dbv=|srv=
Adding reference to C:\x\.nuget\packages\msdb\1.0.0/tools/msdb.dacpac with external parts dbl=|dbv=|srv=
....
....
Adding C:\xxxxx\ToUTC.sql to the model
Deleting existing file C:\xxxx\obj\Debug\net5.0\MESF.Core.Database.dacpac
Writing model to C:\xxxx\obj\Debug\net5.0\MESF.Core.Database.dacpac
C:\Program Files\dotnet\sdk\5.0.203\Microsoft.Common.CurrentVersion.targets(4474,5): error MSB4044: The "CopyRefAssembly" task was not given a value for the required parameter "SourcePath". [C:\xxxx\MESF.Core.Database\MESF.Core.Database.csproj]
Hmm, this is interesting. I haven't seen this before, while we've been using .NET 5 for quite some time now. Maybe @jeffrosenberg or @ErikEJ have? I do wonder what triggers this behaviour.
It would be interesting to have a look at a binary log file, which can be obtained by using dotnet build /bl. It is important to note however that the binary log file includes a dump of your environment variables, so perhaps you want to share it with me privately by sending it to jonathan.mezach at rr-wfm.com so that I can have a look. Ideally I'd like to have one with and one without the ProduceReferenceAssembly flag.
I'm trying to compile a project with source files inherited from a nupkg using this
I'm able to include the source .sql files in the project but they don't compile, I think the reason is that they have buildAction=compile, while in sqlproj.sdk the .sql files are marked as "content" , what can I do to force the compilation?
this is a glimpse of my test project with the sql sources derived from a nupkg

I'm sorry I don't quite understand what you are trying to achieve. SQL files are marked as Content rather than Compile since they aren't actually being compiled. I guess we could have gone with Compile from the get go, but changing this now would essentially be a breaking change, which I'm reluctant to make currently because I don't quite understand the scenario here.
I posted this in the wrong thread, I'll open a new one and try to be clearer. This thread was about the "ref" folder created by net5.0 and a weird build error associated with it.
I'm getting the same error when compiling with net5 on both Windows and Ubuntu.
<Project Sdk="MSBuild.Sdk.SqlProj/1.16.0">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<SqlServerVersion>Sql130</SqlServerVersion>
</PropertyGroup>
</Project>
Error:
/usr/share/dotnet/sdk/5.0.301/Microsoft.Common.CurrentVersion.targets(4520,5): error MSB4044: The "CopyRefAssembly" task was not given a value for the required parameter "SourcePath".
But it works fine with netcoreapp2.1 and netcoreapp3.1.
Any reason you can't target netstandard2.0 ? Your SQL is always going to be in its own separate library project anyway, right?
Yeah, the recommendation is to have your SQL project target netstandard2.0. We aren't actually creating an assembly at all, but some things might work differently if you target a specific .NET version.
Same can happen in .NET 6.
When building for .NET 6 you should be using <TargetFramework>netstandard2.1</TargetFramework>
If you instead use net6.0 then by default reference assemblies are generated, causing this issue to arise.
When building for .NET 6 you should be using
<TargetFramework>netstandard2.1</TargetFramework>
Of course you can target netstandard2.1, but I don't think there's any reason you can't continue to target netstandard2.0 - That's what I'm doing for now at least.