Git Product home page Git Product logo

Comments (31)

jmezach avatar jmezach commented on May 17, 2024 3

@shawty The project file must have the .csproj extension. It will not work with .sqlproj because then Visual Studio will interpret it as an old style project, but since you've changed the contents of the project file to use SDK-style projects you get the error. I don't think there's currently a way we can support the .sqlproj extension.

from msbuild.sdk.sqlproj.

ErikEJ avatar ErikEJ commented on May 17, 2024 2

Maybe the documentation could be slightly clearer on that?

from msbuild.sdk.sqlproj.

jmezach avatar jmezach commented on May 17, 2024 2

What I've heard people do is to have a "companion" .csproj next to the existing .sqlproj. I believe @ErikEJ has some experience with that as well. Basically you would create a new project (I believe it has to be in a separate folder as well) and then add the following to your project file:

<ItemGroup>
  <Content Include="../<sql-proj-folder>/**/*.sql" />
</ItemGroup>

You can then use the .csproj for CI and use the .sqlproj for editing.

from msbuild.sdk.sqlproj.

ErikEJ avatar ErikEJ commented on May 17, 2024 1

I have a blog post here describing the "buddy" project scenario: https://erikej.github.io/efcore/2020/05/11/ssdt-dacpac-netcore.html

from msbuild.sdk.sqlproj.

ErikEJ avatar ErikEJ commented on May 17, 2024 1

Maybe a simple change to the docs:

Usage
The simplest usage is to create a new .csproj project file with the following contents:

from msbuild.sdk.sqlproj.

shawty avatar shawty commented on May 17, 2024 1

Annnnnndddddd.... W0000000 H00000000 :-)

On a hunch, I turned off building of actual db project solution wide, and now everything works perfectly.

image

🎉🎉🎉🎉

from msbuild.sdk.sqlproj.

shawty avatar shawty commented on May 17, 2024 1

LOL... I won't copy it, but I will follow the same process, just using my own words.

from msbuild.sdk.sqlproj.

jmezach avatar jmezach commented on May 17, 2024 1

Thanks @ErikEJ for updating the docs. I think there isn't much more we can do here.

FYI: I've recorded a dotnetFlix episode today about this project demoing it which also goes into converting an existing project, etc. Should be coming online soon.

from msbuild.sdk.sqlproj.

ErikEJ avatar ErikEJ commented on May 17, 2024

Could you share your .csproj ?

from msbuild.sdk.sqlproj.

shawty avatar shawty commented on May 17, 2024

Yea sure Erik, but there's nothing special in it, it's just the standard template one. (sqlproj) I think it is.

image

image

image

image

This ^^^^^ above, plus the attached ".sqlproj" file, is the original project files

st_database.sqlproj.zip

I then replaced the sqlproj file created by the template with

image

as suggested in this projects readme.

That got me to the point where I can do this

image

but where reloading it into VS19, gives me this

image

from msbuild.sdk.sqlproj.

shawty avatar shawty commented on May 17, 2024

I confess I did spend an hour or two last night chopping and changing bits of the project file around, but didn't get anywhere.

from msbuild.sdk.sqlproj.

shawty avatar shawty commented on May 17, 2024

@jmezach ah ok. So question? It's not 100% clear from the read me, but how would I get an SQL server style project into my .NET core solution?

From scratch?

Basically, I would like to use the features of VS to help me edit, design and build the new tables/sprocs/fuctions etc, and maybe even generate a DACPAC for them (Although this is not a major requirement).

Then when checking into git, I still want my CI/CD to build the solution (I don't care too much if the SQL server stuff is built or not) but I don't want the SQL project to break my CI Build, which is what it's doing at present with just the normal standard SQL Server project files.

I ended up here, after several searches as this being the solution to that problem :-)

Sorry I'm rambling a bit :-)

In a nutshell, I want to be able to use VS19's SQL editing features, and be able to check in the SQL code along side all the CS code, but still have my CI service build the solution and produce the output on the Linux build server it's using. Everything is Core based, and the build is performed using the standard "dotnet" cli tools.

from msbuild.sdk.sqlproj.

shawty avatar shawty commented on May 17, 2024

@jmezach Thanks, I'll give that a try and let you know how I get on.

from msbuild.sdk.sqlproj.

shawty avatar shawty commented on May 17, 2024

Maybe the documentation could be slightly clearer on that?

Absolutley Erik.

Everything I've read that lead me to this point, suggests that your project is the solution, for not only my case, but TFS based builds that break with the same tooling errors too.

The best way to test it, is to build a regular .NET core web-api service, then add a new project to that solution, and make the project type be an SQL one. Then use a linux machine set up with the standard .NET core tools, to perform a "dotnet build" from the cli, at solution level, so all the projects are built in one go.

You'll get something similar to my first image in the thread, and searching in those exceptions, will eventually lead you to here.

Some documentation changes, and/or possibly a page in the wiki telling people how to convert an SQL server project to build with the CLI tools in this case would be very helpful.

from msbuild.sdk.sqlproj.

shawty avatar shawty commented on May 17, 2024

Yep, that makes it clearer that you shouldn't replace the SQL Project.

I would also put the link to your blog post in there too.

At a minimum I would say

"The simplest usage is to create a new .csproj project file, alongside all the existing files, with the following contents:"

from msbuild.sdk.sqlproj.

jeffrosenberg avatar jeffrosenberg commented on May 17, 2024

Our usage may not be typical, but what we're doing on my team is committing only the .csproj file, but maintaining a script that can be used to generate the .sqlproj file on an adhoc basis. Because the .csproj file supports wildcards, it doesn't need to be changed with each commit like the .sqlproj file does. So most of the time, we rely on just the .csproj file and develop in a text editor. When we need to use SSDT, we generate a new .sqlproj file and open that in SSDT.

from msbuild.sdk.sqlproj.

shawty avatar shawty commented on May 17, 2024

thanks @jeffrosenberg more fuel for the fire :-)

from msbuild.sdk.sqlproj.

shawty avatar shawty commented on May 17, 2024

Still getting a bit stuck here.

Trying Erik's approach from his blog post, and dotnet core build is getting confused.

image

from msbuild.sdk.sqlproj.

shawty avatar shawty commented on May 17, 2024

and if I try it at solution level:

image

from msbuild.sdk.sqlproj.

ErikEJ avatar ErikEJ commented on May 17, 2024

As @jmezach wrote, and as clearly stated in my blog post, do not have both the .sqlproj and .csproj in the same folder.

from msbuild.sdk.sqlproj.

shawty avatar shawty commented on May 17, 2024

ah ok, I missed that bit... dunno why... ok, trying again.

from msbuild.sdk.sqlproj.

shawty avatar shawty commented on May 17, 2024

Even with everything in 2 separate projects, the command line build still fails.

image

In VS19 all is ok :

image

But the command line has gone back to my very first error now, failing because it can't find the SSDT tools

@ErikEJ as far as I can see, I've done everything the same way as in your blog post

ServiceThreadWeb.zip

from msbuild.sdk.sqlproj.

ErikEJ avatar ErikEJ commented on May 17, 2024

You need to exclude the .sqlproj from your build configuration.

from msbuild.sdk.sqlproj.

shawty avatar shawty commented on May 17, 2024

You need to exclude the .sqlproj from your build configuration.

Github didn't update the page until I posted my reply....

from msbuild.sdk.sqlproj.

shawty avatar shawty commented on May 17, 2024

@ErikEJ if you don't object, I'm gonna blog this, and point folks both at your blog post, this project/issue and repeat the steps from your post with a bit extra detail.

Cheers
Shawty

from msbuild.sdk.sqlproj.

ErikEJ avatar ErikEJ commented on May 17, 2024

Excellent, the more noise the project makes, the better! (as long as you do not copy my blog post, of course)

from msbuild.sdk.sqlproj.

ErikEJ avatar ErikEJ commented on May 17, 2024

I have updated my blog post.

from msbuild.sdk.sqlproj.

ErikEJ avatar ErikEJ commented on May 17, 2024

Looking forward to watching!

from msbuild.sdk.sqlproj.

shawty avatar shawty commented on May 17, 2024

@jmezach kewl, I'll have to watch that. I'll reference it from my blog post too, which I'll be writing later on this evening.

from msbuild.sdk.sqlproj.

shawty avatar shawty commented on May 17, 2024

@jmezach by the way if your interested, I routinely do sessions for .NET channels and such like, so if you'd like me to do a video session on dotNetFlix, do feel free to reach out to me. I'm one of the management team behind "LiDNUG (The Linked .NET Users Group on Linked-in)" (Lidnug.org) if you want to get in touch.

from msbuild.sdk.sqlproj.

shawty avatar shawty commented on May 17, 2024

@ErikEJ and others - blogged : https://shawtyds.wordpress.com/2020/08/26/using-a-full-framework-sql-server-project-in-a-net-core-project-build/

from msbuild.sdk.sqlproj.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.