I have a nothing-special .NET Core solution, lets call it Application.sln
, and it contains 12 C# projects, and 1 SQL project. In Visual Studio 2017, I have no issue building all the projects, but when I head to the command line to package up the projects using dotnet pack Application.sln --no-build
, I immediately run into an issue with the sql project. Here is the error:
error MSB4019: The imported project "C:\Program Files\dotnet\sdk\1.1.0\Microsoft\VisualStudio\v14.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
After deciphering that, I found out that the first part, C:\Program Files\dotnet\sdk\1.1.0
comes from me using dotnet instead of msbuild to package up the solution, and since SSDT cannot be installed into the dotnet folder, this will fail.
Preferably, I would like it to ignore the .sqlproj project and only pack the .csproj projects as I will be handling the sql projects separately afterwards, but I do not see any way to do that. Is there a way? It does not appear that I can use MSBuild style wild cards as a parameter to dotnet pack
(***.csproj) as that throws a separate error.
I have tried using msbuild /t:pack but that gives me other issues (it says the target "pack" does not exist in the project).
Does anyone have any suggestions for me? If it helps, I am wanting to do this through TeamCity, but all of these issues exist on my development machine as well.
To add an item to a solution, on the context (right-click) menu of the solution node in Solution Explorer, select Add > New Item, or Add > Existing Item. A solution file is a structure for organizing projects in Visual Studio.
One method of adding references to your library is by typing it directly in the project. json file. As you can see that we have added some references under the dependencies section as shown in the following code. Let us now save this file and you will see that references are added to your library now.
A file with . SLN extension represents a Visual Studio solution file that keeps information about the organization of projects in a solution file. The contents of such a solution file are written in plain text inside the file and can be observed/edited by opening the file in any text editor.
First, if you want to use the dotnet
tools, you will need to create a second solution that contains only the c# projects. If you don't want to do this, you can always use the msbuild commands directly from the VS 2017 developer command prompt (dotnet restore
=> msbuild /t:Restore
etc.)
The Pack
target is only available for projects with integrated NuGet package support, which comes through using the Microsoft.NET.Sdk
SDK ("new" csproj format) or using the NuGet.Build.Tasks.Pack
nuget package in projects that are compatible with it.
If you want to call dotnet pack
/ msbuild /t:Pack
on a solution without creating a second solution without the sql projects, all projects must contain a pack target.
An easy way to do that is to create a Directory.Build.props
file next to the solution with the following contents:
<Project>
<Target Name="Pack" />
</Project>
This file will be automatically imported at the beginning of all projects in the directory hierarchy and define an empty Pack
target in them. Projects using the .NET SDK will then overwrite this target with the actual NuGet pack targets. So msbuild /t:Pack
will call this empty target on the SQL project and the original NuGet Pack
target on the c# projects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With