CHUVASH.eu

CHunky Universe of Vigourous Astonishing SHarepoint :)

Tag Archives: Visual Studio

Working with resx files in Visual Studio

Today I found a nice Visual Studio Extension for working with localization and resx files: Resx Resource Manager. This extension provides an additional view in your project and scans all the resx files. I would recommend it to all projects where you have to translate your interface. Here is how it looks in my project:

resx-001

It can also assist with some machine translation from Bing and MyMemory:

resx-002

Another good thing is the Export and Import to and from Excel. Wonderful if you need help from Non-developers.

resx-003

TypeScript in SharePoint

By now TypeScript shouldn’t be something one has to introduce.

TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.

If you haven’t already done it, go and see the intro video for TypeScript, check out a tutorial and visit the typescript playground. There are other javascript libraries which extend javascript and are compatible/compile to javascript: Dart and CoffeeScript. To be honest I had never time to try those. The fact that TypeScript is well integrated into Visual Studio which I happen to work within all the days (intellisense, compilation checks and more) did me curious.

This post is actually not about TypeScript itself, but a test to use it in SharePoint. In this short “lab” I even had Web Essentials 2012 which automatically compile typescript files into plain javascript files on save.

This is what I did:

Install TypeScript and Web Essentials 2012

Create a SharePoint-hosted app:

Create a new TypeScript file in the autogenerated “Scripts”-module and call it “Greeter.ts”

Just save the file as it is. The new file is created: Greeter.js

Now we don’t need to copy this file to the app, so remove Greeter.ts from the Elements.xml file (or comment it out):

Open the Default.aspx from the Pages module and add the reference to the new javascript file:

<script src="../Scripts/Greeter.js"></script>

Then deploy your app. Once it is deployed we can see in the dev tools that our code is there:

Minifying the files…

Another tip is to minify the autogenerated javascript file. Right-click on the file -> Web Essentials -> Minify the files.

This will generate the Greeter.min.js file:

.tfignore – “.gitignore” for TFS

I haven’t used TFS so much. But I like it so far. It works smoothly, both TFS 2012 (on premises) and TFS Preview (online). I really appreciate that Microsoft has been inspired from git – the world’s best VCS :). For example .tfignore which works exactly like the .gitignore file. It is nice that the non-classic Microsoft dot notation convention for naming the hidden files is chosen.  So if you have any files to ignore just do it like you did in your git projects. Here is a .tfignore which I use in my SharePoint project for now. I suppose it will be extended soon:

######################################
# Ignore Reshaprer files
*_ReSharper.*
*.DotSettings
# 
# Ignore published wsp outputs
*.wsp

Put .tfignore file in the root of your TFS Project. You can of course, let VS2012 create it automatically in the VS2012

Simplify js and css development with Web Essentials (Visual Studio Extension)

If you develop much javascript and css, this is the exension to Visual Studio you just can’t live without: Web Essentials (It is even released for VS2012).

You can do many things with it. Here are two examples for simple but very useful functions:

1. Show which browsers support a css attribute:

2. Collapse javascript functions and create #region areas like in C# code:

There is much more, like less and coffeescript parsing. Just check the documentation. And it is fully appliable in SharePoint development.

Less and Coffeescript

Now using less and coffeescript (update: and typescript) can be really easy even in SharePoint. Whenever you save a .less file or .coffeescript, it will create a corresponding file with .css or .js file extensions in the same folder. So you can write your styles in less and scripts in coffeescript and reference the auto-generated css and js files.

UPDATE: For some reason the css is not generated when I run Visual Studio 2012 on Server 2008 with Web Essentials, but it works fine on my Windows 8 machine. To play around with less, you can use this demo site (creds to @irishbuzz on so).

 

Next: Typescript and SharePoint

The original Visual Web Part template is missing in Visual Studio 2012

Today I encountered a weird issue, the classic Visual Web Part template was gone in Visual Studio 2012. When I created a Visual WebPart, a webpart was created with a generated .g.cs file, like the sandboxed visual webparts. I am not exactly sure why it happened. According to the MSDN guide Creating Web Parts for SharePoint, the structure of Visual Webparts should be the same as in Visual Studio 2010. It could have happened after I installed the power tools.

However, if someone runs into the same issue, here is the solution:

Copy this zip file from a computer with VS2010 installed:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\SharePoint\SharePoint14\1033\SharePoint14VisualWebPart.zip

Unpack it.

Edit SharePointVisualWebPart.vstemplate. Change the assembly line so it references to the Version 11:

<Assembly>Microsoft.VisualStudio.SharePoint.ProjectExtensions.Wizards, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>

After that copy the directory SharePoint14VisualWebPart to these two locations on your computer with Visual Studio 2012 installed.

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ItemTemplates\CSharp\SharePoint\SharePoint14\1033\
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ItemTemplatesCache\CSharp\SharePoint\SharePoint14\1033\

Just to be safe, save the SharePoint14VisualWebPart (which have the same name) by appending “.bak” to the name.

If you don’t have an access to a VS2010 computer, I have saved the template for you on github.

Develop for SharePoint on Windows 8

Do you like Windows 8 user expirience, as me? Well than you want to try developing sharepoint solutions in Windows 8. Here I will show what I found out.

Environment

I installed Windows 8 Release Preview as a VMWare machine. Then I installed Visual Studio 2012 RC. Then I followed the steps for installing SharePoint on Windows 8 which are more or less the same as for Windows 7 client install. But then I encountered an error I haven’t found solution for yet. In my standalone sharepoint installation there were some permission problems:

Failed to create the configuration database.

An exception of type System.Data.SqlClient.SqlException was thrown. Additional information:
Cannot find the object ‘proc_putDeletedSiteMap’,because it does not exist or you do not have permission.

Plan B

In a meanwhile I tried to just to use Andrew Connell’s trick: to copy sharepoint dlls to GAC and the 14 folder. To extract the sharepoint dlls, you can use a script from sharepoint tech blog:

mkdir c:\temp
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Portal")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Policy")
[appdomain]::currentdomain.getassemblies() |
where {($_.fullname -match "Microsoft.Office") -OR ($_.fullname –match "Microsoft.SharePoint")} |
copy-item -path {$_.location} -destination c:\temp\ -verbose

Then copy the dlls to gac with gacutil.

This plan B works, but with one shortcoming: you can’t debug, neither you can create new sharepoint solutions, you’ll get an error: “SharePoint Not Installed”.

What you have to do is to open an existing sharepoint solution. And you can build it and publish. After I opened an existing solution in Windows 8, I could create new solutions as well :).

The most awesome feature in Visual Studio 2012 is the ability to publish your projects:

Todolist in VS

A really nice feature is a task list. Just write //TODO something something in your code and it appears in the task list which can be shown through View – Task List in Visual Studio.

Aktivera intellisense för javascript i VS

Det finns ett sätt att aktivera intellisense för javascript i VS:
Klistra in det i ditt js-fil eller aspx:

/// <reference name="MicrosoftAjax.js" />
/// <reference path="file://C:/Program Files/Common Files/Microsoft Shared/Web Server Extensions/14/TEMPLATE/LAYOUTS/SP.core.debug.js" />
/// <reference path="file://C:/Program Files/Common Files/Microsoft Shared/Web Server Extensions/14/TEMPLATE/LAYOUTS/SP.debug.js" />

Men tyvärr kommer det inte funka om du har installerat Resharper.
Eller lägg till vanliga script-taggar som beskrivet i boken Sharepoint As Developer Platform:

<asp:PlaceHolder ID="PlaceHolder1" runat="server" Visible="false">
	<script type="text/javascript"
		src="file://C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\MicrosoftAjax.js" />
	<script type="text/javascript"
		src="file://C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\SP.Runtime.debug.js" />
	<script type="text/javascript"
		src="file://C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14 \TEMPLATE\LAYOUTS\SP.debug.js" />
	<script type="text/javascript"
		src="file://C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\SP.Core.debug.js" />
	<script type="text/javascript"
		src="file://C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14 \TEMPLATE\LAYOUTS\SP.Ribbon.debug.js" />
</asp:PlaceHolder>

UPDATE 2012-03-03: An example of it in 101 code samples.

ForEach-metod i List

En intressant variant av foreach är ForEach-metoden i List.

Titta på det lilla exemplet:

private static void SavePlacesToDB(SQLiteConnection cnn, 
                                     List<dynamic> places)
{
    places.ForEach(obj => SavePlaceToDB(obj, cnn));
}

Här används även det nya objektet dynamic som har kommit i Visual Studio 2010, samt en lambda expression (=>).

Вула Чăвашла

VulaCV - Чăвашла вулаттаракан сайт

Discovering SharePoint

And going crazy doing it

Bram de Jager talking Office 365, SharePoint and Azure

My view and thoughts on Productivity and more.

My programming life

and everything in between

SharePoint Development Lab by @avishnyakov

It is a good place to share some SharePoint stories and development practices.

SharePoint Dragons

Nikander & Margriet on SharePoint

RealActivity - Real-time and trustworthy

Blog site of founder, RealActivty - Paul J. Swider

Mai Omar Desouki - Avid SharePointer

Egyptian & Vodafoner - Senior SharePoint Consultant

Cameron Dwyer | Office 365, SharePoint, Outlook, OnePlace Solutions

Office 365, SharePoint, OnePlace Solutions & Life's Other Little Wonders

paul.tavares

Me and My doings!

Share SharePoint Points!!

By Mohit Vashishtha

Jimmy Janlén "Den Scrummande Konsulten"

Erfarenheter, synpunkter och raljerande om Scrum från Jimmy Janlén

SPJoel

SharePoint for everyone

SharePointRyan

Ryan Dennis is a SharePoint Solution Architect with a passion for SharePoint and PowerShell

SharePoint 2020

The Vision for a Future of Clarity

Aharoni in Unicode, ya mama

Treacle tarts for great justice

... And All That JS

JavaScript, Web Apps and SharePoint