Now if you want to contribute some code or not, I can recommend to check these guidelines. There is a lot of useful information inside. (Always cool to look inside the head of the Microsoft software engineers )
Friday, February 27, 2015
Thursday, February 26, 2015
In Visual Studio 2013, the SQL Server Data Tools are available out-of-the-box. They give you a new project template, the Database project, that allows you to manage your database objects and scripts in a structured way.
In this post I want to explain how you can enable continuous integration and automatically deploy your database changes each time you check-in some code.
Before we start make sure that you created a database project and added some database objects. On your TFS build agent, the SQL Server Data Tools should also be installed. If you are using Visual Studio Online(like I will do) together with a hosted Build Controller, the Data Tools are already installed.(Here is the full list of installed components: http://listofsoftwareontfshostedbuildserver.azurewebsites.net/)
Add a Publish Profile
Open Visual Studio and load your Database Project. Once Visual Studio is ready, right-click on your Database Project and click on Publish…
The Publish Database window is loaded. Click on Edit… to add a connection string to the database where you want the database project published to. Afterwards click Save Profile As… to save the Publish profile and add it to your Database Project.
As we don’t want to deploy immediately, you can click on Cancel to close the window after the Publish profile is saved.
Creating a new Build Definition
Now everything is configured correctly, it’s time to open up Team Explorer(View –> Team Explorer).
Go to the Builds tab to add a new Build Definition.
Specify a name for your Build and move on to the Trigger tab.
Set the Trigger type to Continuous Integration and jump directly to the Build Defaults tab.
On the Build Defaults tab, select the Build Controller where the SQL Server Data Tools are installed. In my case I’m using Visual Studio Online, so I choose the Hosted Build Controller. I also choose to copy the build results to a Drops folder inside source control. Let’s move on to the Process tab.
On the Process tab, open up the Advanced section and paste the following line in the MSBuild Arguments field:
/t:build /t:publish /p:SqlPublishProfilePath=NorthwindDBProject.publish.xml
Replace the SqlPublishProfilePath value with the name you choose for your Publish Profile in the Database Project.
Save the Build definition, you are done! There are a lot of other things, you can configure, but by default, this should be enough.
Check-in and see what happens…
As a last step, do some changes inside your database project, check them into TFS, and look how your database is rolled out for you…
Wednesday, February 25, 2015
Microsoft Virtual Academy started a new initiative to get you going as a Web Developer: the Web Development Wednesdays. Every Wednesday they release a new web development training session where they explore platforms, frameworks, and everything somewhat related to web development.
From the site:
Web developers, do you want help navigating the modern world of web development? Join us for Web Wednesdays, an online web development training series, as we explore platforms, frameworks, and browsers to connect data and people. Entertaining and informative experts address scalability, design, and performance issues in each of these online web development courses. This training for web developers offers practical tips and explores real-world scenarios to help make your job easier. Don’t miss these opportunities to get the rest of the “web story”!
These sessions are offered for free, so no excuse for not signing up…
Tuesday, February 24, 2015
I created a Build Definition for a build controller in TFS Online. When I try to edit the build definition(Right click –> Edit Build Definition…) and go to the Process tab, the only thing that shows is a ‘Preparing build definition environment’ message and an endless spinning wheel…
I found the issue on Connect but it was closed as ‘Not reproducable’ . Anyone with a solution?
Update: The workaround mentioned on the Connect site; repairing Visual Studio; solved the problem for me.
Monday, February 23, 2015
Friday, February 20, 2015
Sometimes when working with .NET you discover some hidden gems. Some of them very useful, other ones a little bit harder to find a good way to benefit from their functionality. One of those hidden gems that I discovered some days ago is String.Intern().
The String.Intern() method allows you to internalize string values explicitly. Ok, but what does this mean?
In a typical .NET application, the same string values are used over and over again. As this would end up with a lot of duplicated memory, .NET will allocate strings with unique content just once by using the string interning mechanism.
This leads to the question. As this interning is done for you, why do we need this method? The thing is that only explicitly declared string literals are interned on the compile stage. The strings created at runtime are not checked for being already added to the string intern pool.
To solve this problem .NET offers two methods: String.Intern and String.IsInterned. If the string value passed to String.Intern is already in the pool, the method returns the reference to the string. Otherwise, the method adds the string to the pool and returns the reference to it. If you want to just check if a string is already interned, you should use the String.IsInterned method. It returns the reference to the string if its value is in the pool, or null of it isn’t.
Thursday, February 19, 2015
If you like at the OWASP site, you’ll find a while list of common security-related HTTP headers that every web application should implement. These headers are an essential part of building a secure web application.
If you are too lazy to click on the link, here is the full list:
- X-Frame-Options, Frame-Options
- Content-Security-Policy, X-Content-Security-Policy, X-WebKit-CSP
There are multiple ways to add these security headers to you application. You can configure IIS to include them, add some extra ASP.NET (MVC) configuration or you can build some OWIN middleware to add these headers to every HTTP request.
If you decide to use OWIN, be aware that most of the work is already done for you. On GitHub I found the SecurityHeadersMiddleware project which implements most of the headers mentioned above.
The easiest way to get started is to install the package using NuGet: Install-Package SecurityHeadersMiddleware
Inside your startup.cs class, you can now add some code to enable the headers:
More information can be found here.