Building C# 6 with TeamCity

Posted: Thursday, 13 August 2015 18:24 CEST in

After we upgraded to Visual Studio 2015 and started to use some of the new language features in C#6, we got some trouble at work with some of our CI builds. We use TeamCity as build server and we had recently updated to 9.1.1. The builds was using the Visual Studio sln build configuration and was set to Visual Studio 2013.

The error was unexpected character ‘$’. So it was easy to understand that it was the new string interpolation that was causing out build to break.

error CS1056: Unexpected character '$'

The first thing we did was to change the configuration to use Visual Studio 2015, but that only made the build incompatible with all of our build agents.

We then installed the build tools for 2015 and restarted the server. Then the build had compatible agents, and the build worked again. Here is a link to the Microsoft Build Tools 2015

This was for an internal library that now was working again, but there still was a web project that had problems. This time the build was complaining about some missing files.

C:\TeamCity\BuildAgent\...\Web.csproj(1045, 3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

To fix this error, we copied over the files from a computer with Visual Studio 2015 installed to the build server and this build was working again. We actually copied over the whole v14.0 folder.


Bricking your CRM Forms, the ultimate guide

Posted: Monday, 20 October 2014 22:22 CEST in

Loader

The other day I completely bricked a form in Dynamics CRM. The form would just have the command bar and loader up, but nothing happen. This was in a custom entity we use for some settings, and I had a text field which was a template text for SMS sending. This text also had a few template codes that could be used. So in an attempt to be helpful. I added the available template codes in the description for the field. This way I thought it was easy for the user generating this templates to see what template codes that is available in the tool tip.

I had chosen a template format like {{contactname}}, and then I would replace this with the name of the contact when we were sending the SMS. The problem is that this is a pretty widely used format, and CRM uses JsRender, which uses this kind of format as well.

It also took some time to figure out what was wrong, because only Internet Explorer showed something in the console. And IE, was sadly in this case, not the first browser I tried. But when I did try IE, it gave me the error message below, and I immediately understood what had gone wrong.


JsRender Error: Syntax error
Unmatched or missing tag: "{{/contactname}}" in template

Field metadata

So by removing these template codes from the description on the field and publishing again everything was working as expected. I tried using HTML escape characters for the curly braces, but they was only showed as they are typed in. So as far as I know, there is no way to show template codes as these ones in the tool tip.

There is no problem storing these kind of templates in the field itself, but do not put it in the description of the field. There is also no problem storing single curly brackets in the description field either, just stay away from the double.


Hiding menu when printing in Dynamics CRM

Posted: Thursday, 18 September 2014 22:45 CEST in

Recently I had a client requirement that involved printing of CRM pages that contained web resources. The standard print functionality in Dynamics CRM only supports printing static content, so some web resources used on the page being printed was omitted. The user wanted to use the browsers print capabilities and it all worked great, except that the Dynamics CRM header was included on the top.

Print preview showing CRM menu

As you can see from the picture above, the menu from CRM on the top of the page, taking up some much needed space from other content.

The solution in our case was to do a little unsupported change by injecting some CSS in the page with JavaScript. You will only see this change when printing because of the media in the CSS is set to print.

$('head').append('<style>@media print { #crmMasthead, #crmTopBar {display: none !important;} #crmContentPanel {top: 0 !important;}}</style>');

As you can see below, the menu is now gone and we get some extra space on each page when printing.

Print preview showing page without CRM menu


New blog

Posted: Sunday, 07 September 2014 23:01 CEST in

I have planned for a long time now to change blog platform, this weekend I finally got around to it. My choice for blog platform is Jekyll and Jekyll bootstrap. The blog is now hosted on GitHub pages. I have changed the default design form Jekyll bootstrap a bit, but it is still pretty plain and I guess that reflects my design skills :)

Now I just have to start blogging on a more regular basis.


Web Resource Utility and CRM with Office 365

Posted: Wednesday, 17 July 2013 00:00 CEST in

If you wish to use the Web Resource Utility that comes with CRM 2011 SDK on an CRM Online organization from Office 365, you will not be able to connect to the discovery service.

When you type in your credentials and server address you will get the error message shown below.

Error message

This is because the Web Resource Utility uses

https://dev.[address_typed_in]/XRMServices/2011/Discovery.svc

That is correct for CRM Online as the discovery service, but not when you have CRM from Office 365. Office 365 instances of CRM uses disco insted of dev in the URL. So a correct URL for a CRM Online from Office 365 is

https://disco.[address_typed_in]/XRMServices/2011/Discovery.svc

For more info on the differnet discovery services see MSDN

Luckily there is an easy fix to the problem. In the method GetServerConfiguraton in the class ConsolelessServerConnection we have to change the DiscoveryUri.

Open the file and simply change the line

config.DiscoveryUri = new Uri(String.Format("https://dev.{0}/XRMServices/2011/Discovery.svc", config.ServerAddress));

to

config.DiscoveryUri = new Uri(String.Format("https://{0}/XRMServices/2011/Discovery.svc", config.ServerAddress));

After this change you will have to specify dev/disco part to use the tool, but it will work for both “regular” CRM Online and CRM Online from Office 365.

Connection window


About Sebastian

Sebastian Holager

Sebastian Holager is a developer working at a CRM Norge in Oslo, Norway. At day time hacking away on Dynamcs CRM, C# and JavaScript. While at night playing around with other programming languages, reading and watching football.

Follow me on twitter