How to specify database for Database Project and deploy? - visual-studio-2012

I created a Database Project in VS 2012, but how do I specify a database connection for it so that it uses the database context for Intellisense tips and for deployment?
Also, to deploy to the target database, have I call Publish all the time, or can it be done on each build?

Intellisense does not use a connection string to function, it uses the objects (table, views, column, etc) defined in your project.
For deployment, this is done through publishing. You can right-click your project and select Publish... and this will open the Publish Database popup. From there, you use profiles to deploy to the right database with the correct settings.
Once you have profiles created, they will appear as file in your project, you can then double-click those and then publish your database using that profile.
As for publishing each time you build the project, I never tried it, but this can probably be accomplished by changing the targets your project use building. By default, your project looks like this:
<Project DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
ToolsVersion="4.0">
Try changing this to
<Project DefaultTargets="Build;Publish"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
ToolsVersion="4.0">

Related

How to build .sqlproj requiring SSDT in a linux docker container?

I want to build a .sqlproj inside a linux container. The problem is that building the .sqlproj is dependent on SSDT and so far I can't find SSDT that can be installed as standalone on linux.
Error I see running 'dotnet msbuild' in my container:
error MSB4019: The imported project "/usr/share/dotnet/sdk/2.2.402/Microsoft/VisualStudio/v11.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.
Searching the .sqlproj file for the issue, I see we are trying to import a Schema.SqlTasks.targets file, which I'm assuming SSDT creates:
<Import Condition="'$(SQLDBExtensionsRefPath)' == ''" Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" />
I see the same error testing out 'dotnet build'
There is a Windows standalone option:
https://learn.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt?redirectedfrom=MSDN&view=sql-server-ver15
https://www.nuget.org/packages/Microsoft.Data.Tools.Msbuild/10.0.61804.210
Has anyone found a way to provide SSDT in a linux container?
Goal State: The build step to generate the dacpacs would occur inside the container.
Current State: For now I'm using Visual Studio on my machine as the build machine, then copying the dacpacs up to the container where sqlpackage.exe can then publish the schema.
Why Linux? This dockerized DB will support a stack of services running in linux containers, so a windows container is not ideal.
Ok, so with a bit of help from ErikEJ and other members of the community, at the GitHub link given to you by Brett Rowberry in the comments, I finally figured out how to do this.
The steps to follow are quite simple.
Add your SQL Server project
Add a .NET standard class library project and call it something like "database.build"
remove all the code from the class library project, and modify the csproj file so it reads something like the following
Change the properties on your solution so as to NOT build the sql server project for all configurations.
Once you done this, you'll find that you still get access to the SQL database project in visual studio, and get all the syntax highlighting and intellisense, but your CI will build the SQL code via the linked class library and produce a dacpac in it's output folder ready to be deployed.
Right clicking on the project will allow you to build it from within Visual Studio, and right clicking and selecting "Publish" will allow you to specify your database parameters and publish it to the DB server being used. If you have other objects already in your database that you need to reference, you can create an object only dacpac from the database, using SQL server management studio, which you can then add to your project and check in with it's sources so that you do not need to recreate every single object you may already have.
I've written a blog post explaining it all at length here:
https://shawtyds.wordpress.com/2020/08/26/using-a-full-framework-sql-server-project-in-a-net-core-project-build/
I had the same issue what I did as a workaround:
1- Generated sql script from database project "Generate Script"
2- Followed this code sample to run the script on the Linux container
https://github.com/microsoft/mssql-docker/issues/2#issuecomment-547699532
https://github.com/lkurzyniec/netcore-boilerplate/tree/master/db/mssql
https://github.com/lkurzyniec/netcore-boilerplate/blob/master/docker-compose.yml

EscapeTextForRegularExpressions error while webdeploying to azure

In my asp.ent MVC4 project, I am using webdeploy to deploy to azure and I deployed this project to the app service on azure several times before. but out of a sudden I have this error.
"EscapeTextForRegularExpressions" task was not given a value for the required parameter "Text"
I Have found an answer:
Add this file into the web project in its root folder.
File Name : *.wpp.targets
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ExcludeFromPackageFolders Include="Internal">
<FromTarget>*.wpp.targets</FromTarget>
</ExcludeFromPackageFolders>
</ItemGroup>
</Project>
Never the less I cannot understand the real cause of the problem
According to your description, I found a similar issue noted the IncludeIisSettings within *.csproj. Per my test, if I specified the <IncludeIisSettings>true</IncludeIisSettings> with my csproj, then when I use the Web Deploy method from the Publish wizard of VS, I could encounter the similar issue as follows:
After remove the IncludeIisSettings or set the value to false, then I could deploy my web application to azure web app successfully.
I have another answer maybe can help someone:
You must open the Solution explorer then right-click the project, select properties, on Package/Publish Web check your Configuration is on Release and not on Active (Debug) in the drop-down, this was the solution in my case.

How to deploy Azure service fabric project on to a remote cluster(Azure)

I have Created a cluster in Azure http://******.######.cloudapp.azure.com:19080
but don't know how to deploy my service fabric project on to it.
Link to application manifest
ApplicationManifest.xml
It's pretty well documented, unless you are getting specific errors, which you then will need to reference to get some worthwhile help
https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-publish-app-remote-cluster
Your first option is to use the powershell commands. You can also right-click your application in visual studio and select "Publish". Make sure you are using the correct publish profile.
Within Visual Studio, navigate to your Publish Profiles folder under the application and copy/paste the existing cloud.xml file and then rename appropriately. Ensure that you use the correct public facing I.P for your cluster, which will most likely be the load balancer.
The line should look like the following.
<ClusterConnectionParameters ConnectionEndpoint="<YOUR IP>:19000" />
Example:
<ClusterConnectionParameters ConnectionEndpoint="151.41.35.35:19000" />
However, if the cluster is secured you may need additional information. These options are shown within the commented Cluster Connection Parameters of the cloud.xml file.
Right click on the application, select publish and ensure the new publish profile is selected. Visual studio will attempt to validate the connection. Try to publish and keep an eye on the output window for insight in to the process.

Error WAT200: No default service configuration "ServiceConfiguration.cscfg" could be found in the project

After installing Visual Studio Enterprise 2017 (Version 15.1 (26403.7)) my Azure Cloud Service does no longer build and gives me the 'Error WAT200: No default service configuration "ServiceConfiguration.cscfg" could be found in the project'. Although it still works fine with Visual Studio Enterprise 2015. (The right TargetProfile is also specified...)
I ran into this last night.
It actually happens when you rename Cloud Service configurations away from Cloud and Local.
In my case, I had deleted the Cloud configuration and created a new, differently named one.
By ensuring that the configurations are called Cloud and Local, the Cloud Service projects will build again using "Resharper build", and (most likely) under "Lightweight solution load".
The configurations can be renamed by right-clicking one of the service roles under the Cloud Service node in Solution Explorer, choosing Properties, then opening up the "Service Configuration" dropdown and clicking <Manage...>.
Now, in the resulting dialog, the configurations can be renamed:
The following bug report got me on the right track:
https://youtrack.jetbrains.com/issue/RSRP-450390
The best way is to change the service configuration prefix in ccproj of your project, add yourprojectname.configurationname
Dot is the life saver.
<ServiceConfigurationPrefix>yourproject.ServiceConfiguration</ServiceConfigurationPrefix>
Add these in itemgroup:
<ServiceDefinition Include="yourproject.ServiceDefinition.csdef" />
<ServiceConfiguration Include="yourproject.ServiceConfiguration.cscfg" />
Make sure you have renamed your cscfg files from the folder it resides.
Reload
Bingo. It works.
Ok I found it, after disabling the 'Lightweight Solution Load' (which in VS 2017 u can disable by right click on the Solution and then Disable Lightweight Solution Load), the error disappears and the Cloud Service builds again.
Similar to Rishikesh mentioned, but I added a service config entry
<ServiceConfiguration Include="ServiceConfiguration.cscfg" />
to the ccproj. Then copied a configuration, e.g. Production and named it ServiceConfiguration.cscfg. Then reloaded the project. That got the ReSharper to build, but MORE importantly for me at the moment was to figure out how to the get Azure DevOps pipeline to build the solution with multiple Classic WebRole projects in it. That was failing for the SAME reason.

VS 2013 Azure Publish hangs with last Pubxml file

If I publish to Azure Cloud Service using the Cloud Project and follow the publish wizard from it works fine but only if I delete the last Pubxml file (stored in the profile folder) first.
If I try and publish when a Pubxml file already exists it will hang trying to navigate between wizard steps.
Using SDK V2.9.6, although had the same issue on previous versions.
I have multiple subscriptions, and the issue seems to be whilst the Pubxml does store the subscription, it is ignored and the default (first one in the list alphabetically) is used instead.
So if I run a publish where there was a previous Pubxml, it jumps to the Diagnostics page. I click next for the summary and the issue areas are highlighted with a red error indicator (it has the wrong subscription selected by default, and hence it cannot find the correct cloud service). However I cannot click back as it just hangs.
I'm using SDK V2.9.6, and didn't see this problem. Actually, my pubxml files have subscription information included.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<AzureCredentials>{"ServiceManagementEndpoint":"https:\/\/management.core.windows.net\/","ResourceManagementEndpoint":"https:\/\/management.azure.com\/","SubscriptionId":"my-subscription-id"}</AzureCredentials>
...
</PropertyGroup>
</Project>
Which version of Azure SDK is your pubxml files generated from?

Resources