Comments (31)
@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.
Maybe the documentation could be slightly clearer on that?
from msbuild.sdk.sqlproj.
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.
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.
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.
Annnnnndddddd.... W0000000 H00000000 :-)
On a hunch, I turned off building of actual db project solution wide, and now everything works perfectly.
🎉🎉🎉🎉
from msbuild.sdk.sqlproj.
LOL... I won't copy it, but I will follow the same process, just using my own words.
from msbuild.sdk.sqlproj.
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.
Could you share your .csproj ?
from msbuild.sdk.sqlproj.
Yea sure Erik, but there's nothing special in it, it's just the standard template one. (sqlproj) I think it is.
This ^^^^^ above, plus the attached ".sqlproj" file, is the original project files
I then replaced the sqlproj file created by the template with
as suggested in this projects readme.
That got me to the point where I can do this
but where reloading it into VS19, gives me this
from msbuild.sdk.sqlproj.
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.
@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.
@jmezach Thanks, I'll give that a try and let you know how I get on.
from msbuild.sdk.sqlproj.
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.
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.
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.
thanks @jeffrosenberg more fuel for the fire :-)
from msbuild.sdk.sqlproj.
Still getting a bit stuck here.
Trying Erik's approach from his blog post, and dotnet core build is getting confused.
from msbuild.sdk.sqlproj.
and if I try it at solution level:
from msbuild.sdk.sqlproj.
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.
ah ok, I missed that bit... dunno why... ok, trying again.
from msbuild.sdk.sqlproj.
Even with everything in 2 separate projects, the command line build still fails.
In VS19 all is ok :
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
from msbuild.sdk.sqlproj.
You need to exclude the .sqlproj from your build configuration.
from msbuild.sdk.sqlproj.
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.
@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.
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.
I have updated my blog post.
from msbuild.sdk.sqlproj.
Looking forward to watching!
from msbuild.sdk.sqlproj.
@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.
@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.
@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)
- EXEC warning SQL73162 --> Option TrustServerCertificate is missing HOT 2
- Support for linked servers HOT 5
- Referencing Microsoft.SqlServer.Dacpacs.Master fails HOT 5
- Referencing projects through `.sqlproj` files HOT 2
- Unable to drop tables, functions and procedures HOT 3
- Unrecognized command or argument '-p:UseSharedCompilation=false' when running on Github build HOT 9
- The SDK 'MSBuild.Sdk.SqlProj/2.6.1' specified could not be found HOT 3
- Enable marking individual static analyzer rules as error (instead of warning)
- Latest release notes lack some details (unlike previous) HOT 2
- Error MSB4018: System.NullReferenceException for an OpenJson operation HOT 2
- Add ability to update current rules or bring your own HOT 6
- Problem with CodeAnalysisRules when using ";" (semicolon) HOT 1
- Enable code analysis by default in the templates HOT 2
- SqlServer.Rules has false positive: SRD0200 HOT 1
- SqlServer.Rules has false positive: SRP0020 HOT 1
- Enable analyzer build warnings as errors to be based on a wildcard HOT 5
- Improve .csproj editing experience
- SQLPackage publish is not working in linux, dacpac built with sqlproject have absolute path to referenced dacpacs HOT 2
- After Upgrade to 2.7.x unrelated csharp diagnostic errors for sql code HOT 4
- Schema project is not taken into account during script creation HOT 36
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from msbuild.sdk.sqlproj.