My attempts at installing Umbraco via NuGet

Posted on November 14, 2011 by Mikkel Ovesen

I often use Umbraco as a CMS for my web projects, and NuGet for referencing other libraries. This made me wonder whether Umbraco could be deployed via Nuget. The short answer is, it is possible, but it does not work very well. Here is my experience.

I started to read the NuGet docs to figure out what a NuGet package actually is.

NuGet package

A NuGet package is a file that makes it easy to add, remove, and update libraries and tools in Visual Studio projects that use the .NET Framework. A NuGet package is comprised by these three things:

  • tools – The tools folder of a package is for powershell scripts and programs accessible from the Package Manager Console. After the folder is copied to the target project, it is added to the `$env:Path (PATH) environment variable.
  • lib – Assemblies (.dll files) in the lib folder are added as assembly references when the package is installed.
  • content – Files in the content folder are copied to the root of your application when the package is installed.
The above is from the NuGet docs.

The documentation also indicate that NuGet was not designed for a project like Umbraco with so many files and such a complex web.config file. But I wanted to try and see how and if it was actually possible.

The strategy

The Umbraco project consists of libraries/assemblies and content, so it should be rather easy to create the NuGet package.

The first step was to download Umbraco 4.7.1 and go through the required assemblies and web.config. Initially I located assemblies that could already be found on NuGet and added these dependencies to the NuGet package. It later showed, that there would be versioning problems which I was not able to fix.

So instead of using dependencies to other NuGet packages as NuGet was actually intended, I  just added all the assemblies released with Umbraco 4.7.1.

Assemblies

The assemblies that gave me the most trouble was ClientDependency and ICharpCode.SharpZipLib.

ClientDependency was actually already in the NuGet feed, but the configuration transformation made from that NuGet package combined with the web.config transformation from the Umbraco package, yilded an invalid web.config file.  ClientDependency was therefor provided as an assembly directly from the Umbraco package and not as an external dependency.

The assembly ICSharpCode.SharpZipLib was also found in the NuGet feed, but Umbraco 4.7.1 required a specific version (0.85.5.452) that NuGet could not provide, and this assembly was as such also added as a part of the Umbraco package.

Web.config

The web.config configuration file for Umbraco is long and rather complex, and that makes merging of multiple web.config files difficult. The configuration transformation features in NuGet are limited, so you should expect problems when adding the Umbraco package to an existing website. The best results I achieved was when the package was added to an empty website or web application.

But even though a web.config file is almost empty, you should still prepare for some clean up.

Content

The Umbraco 4.7.1 binary release containes more than 1500 files. NuGet was not designed for this number of files and does not handle it very well. A complete package installation can take up to 5-10 min. depending on you machine and SSD/HDD configuration.

Example

The following describes the steps I used to run the Umbraco NuGet package against a web application project and the problems that arose.

1. Open Visual Studio 2010 and create an empty C# web application project

2. Open the NuGet Package Manager Console

3. Write:

Install-Package "Umbraco" -Source "c:\[NuGetPackageFolder]"

NuGetPackageFolder: Replace with the path to the folder containing the Umbraco.4.7.1.nupkg file. Important do not give the full path to the file, just the folder

4. Hit [ENTER] and wait for NuGet to do its work

5. Wait for the following two messages:

Successfully installed 'Umbraco 4.7.1'.
Successfully added 'Umbraco 4.7.1' to WebApplication1.

6. Compile and receive an error from web.config. (Multiple System.Web -> Compilation sections are present)

7. Remove the first and compile and run again

<compilation debug="true" targetFramework="4.0" />

8. At this point everything worked and I was able to follow the usual Umbraco installation steps spacer

Conclusion

Umbraco is a fantastic CMS and NuGet is very cool, but together is not a good idea.

My goal was to find a way for installing Umbraco to a web project via NuGet, and that is not impossible, but I would not recommend it. I find it a lot easier to simply download the Umbraco released ZIP, and then extract and drag all files to my web application project. So that is what I will do spacer

But if you still wants the Umbraco NuGet file, you can download it here.

Share|
Posted in Development, Software | Tagged .net, asp.net, nuget, umbraco, visual studio, vs, vs2010 | Leave a comment

MacBook Pro BootCamp/Windows keyboard schema

Posted on November 9, 2011 by Mikkel Ovesen

Visual Studio 2010 + Resharper

Key Description
FN+ALT+[Right arrow] Go to sub types
FN+ALT+[Left arrow] Go to super types
ALT+SHIFT+F12 Find usages of variable
CTRL+SHIFT+F11 Go to type of variable
CTRL+SHIFT+R Refactor this
CTRL+SHIFT+T Go to file
CTRL+T Go to type
FN+ALT+[ENTER] Generate
Share|
Posted in Development, Mac, Software | Tagged bootcamp, macbook, resharper, shortcut, visual studio, vs2010 | 1 Comment

NHibernate query optimising with HQL expression IN

Posted on November 9, 2011 by Mikkel Ovesen

A note for me to remember.

I have been doing some optimisation of queries done by NHibernate HQL. To optimise I have rewritten some of them to use the HQL IN expression.

Point: important to check the collection parameter, if NULL or Empty, NHibernate criteria will fail.

Share|
Posted in Development, Personal | Tagged nhibernate | Leave a comment

Using OpenCover and NUnit with MSBuild

Posted on November 3, 2011 by Mikkel Ovesen

I am working on a project that has a large code base with a lot of logic. For this project I am trying to adopt a more TDD oriented development approach. This includes unit- and integration testing, as well as code coverage, and yes I do know that a high coverage percentage is not the same as good tests, but on the other hand, a low coverage indicates that more tests need to be written.

We are currently using NUnit.2.5.10.11092 and the code coverage tools I was able to find was NCover, PartCover and OpenCover. NCover is no longer free, and from what I can read it seems like OpenCover is the better choice compared to PartCover.

This blog post describes well some of the differences and features of PartCover vs. OpenCover.

MSBuild

This is the MSBuild configuration file that we are currently using to run unit test and code coverage.

<Project DefaultTargets="Build" xmlns="schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">

  <!-- Application Configurations -->
  <PropertyGroup>
    <NUnit-ToolPath>..\packages\NUnit.2.5.10.11092\tools\</NUnit-ToolPath>
    <OpenCover-ToolPath>..\packages\OpenCover.1.0.719\</OpenCover-ToolPath>
    <ReportGenerator-ToolPath>..\packages\ReportGenerator.1.2.1.0\</ReportGenerator-ToolPath>
    <MSBuildCommunityTasksPath>$(MSBuildProjectDirectory)\..\Libs\msbuild\</MSBuildCommunityTasksPath>

    <!-- Add paths to assemblies to test -->
    <TestAssemblies>..\Tests\Core.Tests\bin\Debug\Core.Tests.dll ..\Tests\Model.Tests\bin\Debug\Model.Tests.dll</TestAssemblies>

  </PropertyGroup>

  <ItemGroup>
    <AllProjects Include="..\Tests\**\*.csproj" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="@(AllProjects)" Targets="Clean" />
  </Target>

  <Target Name="Compile">
    <MSBuild Projects="@(AllProjects)" Targets="Build" Properties="WarningLevel=1" />
  </Target>

  <Target Name="Test" DependsOnTargets="Clean;Compile">
    <!-- /domain=single is not support by the NUnit msbuild task, and it is required for OpenCover coverage test -->
    <Exec Command="$(NUnit-ToolPath)nunit-console-x86.exe $(TestAssembliesPath) /nologo /noshadow /domain=single /output=test-results.xml" />
  </Target>

  <Target Name="Coverage" DependsOnTargets="Clean;Compile">

    <!-- /domain=single is not support by the NUnit msbuild task, and it is required for OpenCover coverage test -->
    <Exec Command="$(OpenCover-ToolPath)OpenCover.Console.exe -register:user -target:"$(NUnit-ToolPath)nunit-console-x86.exe" -targetargs:"/noshadow $(TestAssembliesPath) /domain:single" -filter:"+[Model]* +[Core]* +[Datalayer]*" -output:coverage.xml" />
    <Delete Files=".\coveragereport" />
    <Exec Command="$(ReportGenerator-ToolPath)ReportGenerator.exe coverage.xml "coveragereport" html" />
    <Exec Command="$(ReportGenerator-ToolPath)ReportGenerator.exe coverage.xml "coveragereport" xmlsummary" />
    <Delete Files="coverage.xml" />
  </Target>

  <Target Name="Build" DependsOnTargets="Clean;Compile;Test;" />

</Project>

Running the different targets from command prompt is easy, just type “msbuild [MSBUILD CONFIG FILE].xml /t:[TARGET]”

[MSBUILD CONFIG FILE] should be the name of the file above, [TARGET] can be any of the following Clean, Compile, Test and Coverage.

The Coverage target generates a fine HTML report as well as a XML summary.

Please note that I have not used the NUnit task from MSBuild community as the /domain=single is important, and as it is currently not supported by that task.

Share|
Posted in Development | Tagged c#, msbuild, nunit, open cover, unit test | Leave a comment

Visual Studio 2010 Package load errors

Posted on October 20, 2011 by Mikkel Ovesen

My Windows 7 installation on my laptop broke down, and I then had to completely reinstall Windows 7, Visual Studio etc.

Besides it being a long and tedious process it seemed to go fine. But I started to get the following error messages when Visual Studio 2010 was launched:

The ‘RadLangSvc.Package, RadLangSvc.VS, Version = 10.0.0.0, Culture = neutral, PublicKeyToken = 89845dcd8080cc91′ failed to load

VSTS for Database Professionals Sql Server Data-tier Application did not load

and some other VSTS packages that was unable to load.

I followed the steps described here, and it worked spacer . The steps are also described below:

  1. Close all running instances of Visual Studio 2010
  2. Install the following MSI packages from the installation CD of VS2010, in the folder  \WCU\DAC
  3. DACProjectSystemSetup_enu.msi
  4. TSqlLanguageService_enu.msi
  5. DACFramework_enu.msi
Share|
Posted in Development, Software | Tagged error, visual studio, vs2010 | 1 Comment

Cuda v3.2 template project using C++

Posted on May 18, 2011 by Mikkel Ovesen

Important

The tutorial is missing some compilation, linker, library settings steps. However you can download the template project, it works and has everything setup.

Introduction

  • Download template project source
  • Download executable

I am a developer who has been developing software using .NET and C# for several years. I have never used C or C++, and it has never been required.

I like to investigate new technologies, mainly because I am curious, but also because it could make my daily development work easier or smarter.

Recently my focus has been directed towards GPGPU on the Nvidia Cuda platform.

The programming language for Cuda is called “Cuda C”. The name implies that knowledge of C indeed is required for using GPGPU on the Cuda platform.

I discovered that there exist .NET bindings to the Cuda platform and drivers. However, I find their usage complicated and insufficient, and further more kernel development will still have to done in Cuda C.

These fact made me realise that I would have to learn a bit of C and C++ to use Cuda as it was actually intended by Nvidia. Nvidia provides many samples and suggest that a Cuda development environment on Windows could use Visual Studio and Nvidia Parallel NSight for debugging, profiling etc.

As my knowledge of C and C++ development was severely limited, so was the setting up and configuration of Visual Studio 2008 for Cuda C development.

I have read “Cuda by example…” (developer.nvidia.com/object/cuda-by-example.html), “Programming Massively Parallel Processors…” (www.nvidia.com/object/io_1264656303008.html) and “C Programming Language, 2. edition” (www.pearsonhighered.com/educator/product/C-Programming-Language/9780131103627.page). These books have given me the foundation to start developing using Cuda C and GPGPU.

Setting up Visual Studio 2008 and making the compiler work required some work, but here is what I did.

1. Download and install driver and toolkit

Download Cuda toolkit and the developer driver and install. A restart is probably required. (developer.nvidia.com/object/gpucomputing.html)

2. Start Visual Studio 2008, and create a new project of type Win32 Console Application

Give the project and solution a name (here called Cuda_Template).

spacer

3. Click Next

spacer

4. Select Console application and check the empty project, then click Finish

spacer

5. Add new item called main.cpp of type C++ File

spacer

6. Add the following code the file

#include <stdio.h> 

int main() {

    printf("Hello world...\n);
    return 0;

}

7. Build and try to run the exe file. The output should be

spacer

8. Select Project -> Custom Build Rules…

spacer

9. Select Cuda Runtime API build rule (v3.2)

spacer

10. Add a new file called kernel.cu

spacer

11. Add the following to the file kernel.cu

/* power: raise base to n-th power; n >= 0 */
__device__ int devicePower(int base, int n) {

    int p = 1;

    for (int i = 1; i <= n; ++i) {
        p = p * base;
    }

    return p;
}

__global__ void power( int *base, int *n, int *output, int threadMax ) {

    int tid = threadIdx.x + blockIdx.x * blockDim.x;

    if (tid < threadMax) {
        output[tid] = devicePower(base[tid], n[tid]);
    }

}

12. Right click the newly created file and select properties

spacer

13. Set the “Exclude From Build” and make sure that the project still builds

spacer

14. Create a new file called call_kernel.cu

spacer

15. Add the following to the file call_kernel.cu

#include <cuda_runtime_api.h>
#include "main.h"

// includes, kernels
#include <kernel.cu>

void call_kernel_power(int *base, int *n, int *output, int elementCount) {

    int *dev_base, *dev_n, *dev_output;
    int gridX = (elementCount+ThreadsPerBlock-1)/ThreadsPerBlock;

    cudaMalloc( (void**)&dev_base, elementCount * sizeof(int) );
    cudaMalloc( (void**)&dev_n, elementCount * sizeof(int) );
    cudaMalloc( (void**)&dev_output, elementCount * sizeof(int) );

    cudaMemcpy( dev_base, base, elementCount * sizeof(int), cudaMemcpyHostToDevice);
    cudaMemcpy( dev_n, n, elementCount * sizeof(int), cudaMemcpyHostToDevice);

    power<<<gridX,ThreadsPerBlock>>>(dev_base, dev_n, dev_output, elementCount);

    cudaMemcpy( output, dev_output, elementCount * sizeof(int), cudaMemcpyDeviceToHost);

    cudaFree( dev_base );
    cudaFree( dev_n );
    cudaFree( dev_output );
}

16. Create a new header file called main.h

spacer

17. Add the following content to the file

#define ThreadsPerBlock 128

#include <stdio.h>

void call_kernel_power(int *base, int *n, int *output, int elementCount);

18. Update the main.cpp file with the following:

#include "main.h"

#define N   80000

int main() {

    printf("Power Cuda kernel test from C++\n");
    printf("Testing %d elements\n", N);

    int base[N], n[N], output[N];

    for(int i = 0; i < N; i++) {
          base[i] = 2;
          n[i] = i+1;
          output[i] = 0;
      }

    call_kernel_power(base, n, output, N);

    for(int i = 0; i < N && i < 15; i++) {

          printf("%d^%d = %d\n", base[i], n[i], output[i]);

      }

      printf("Done\n");

    return 0;
}

19. That should be it…

You now have a template that you can work from. When you build the file and run it, I get this output:

spacer

Share|
Posted in Development, Software | Tagged c#, cuda, gpgpu, gpu, visual studio, vs2008 | Leave a comment

Mercurial graph

Posted on May 18, 2011 by Mikkel Ovesen

This is a screenshot of the Mercurial graph, of a project that I am currently is working on.

It kind of looks like a string instrument you want to play spacer

spacer

Share|
Posted in Development, Fun, Software | Tagged graph, hg, mercurial | Leave a comment

NHibernate dirty problem, weird updates