'use strict';

module.exports = function(grunt) {

  // Load grunt tasks automatically
  require('load-grunt-tasks')(grunt);

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  grunt.initConfig({

    // Set this variables for different projects
    projectName: 'your_solution_name_here',

    // These variables shouldn't be changed, but sometimes it might be necessary
    srcPath: './',
    solutionName: '<%= projectName %>.sln',
    dotNetVersion: '4.5.0',
    platform: 'Any CPU',
    styleCopRules: 'Settings.StyleCop',
    ruleSet: 'rules.ruleset',

    pkg: grunt.file.readJSON('package.json'),

    assemblyinfo: {
      options: {
        files: ['<%= srcPath %><%= solutionName %>'],
        info: {
          version: '<%= pkg.version %>',
          fileVersion: '<%= pkg.version %>',
          company: 'hylasoft',
          copyright: ' ',
          product: '<%= projectName %>'
        }
      }
    },

    msbuild: {
      release: {
        src: ['<%= srcPath %><%= solutionName %>'],
        options: {
          projectConfiguration: 'Release',
          platform: '<%= platform %>',
          targets: ['Clean', 'Rebuild'],
          buildParameters: {
            StyleCopEnabled: false
          }
        }
      },
      debug: {
        src: ['<%= srcPath %><%= solutionName %>'],
        options: {
          projectConfiguration: 'Debug',
          platform: '<%= platform %>',
          targets: ['Clean', 'Rebuild'],
          buildParameters: {
            StyleCopEnabled: true,
            StyleCopTreatErrorsAsWarnings: false,
            StyleCopOverrideSettingsFile: process.cwd() + '/<%= styleCopRules %>',
            RunCodeAnalysis: true,
            CodeAnalysisRuleSet: process.cwd() + '/<%= ruleSet %>',
            TreatWarningsAsErrors: true
          },
        }
      }
    },

    mstest: {
      debug: {
        src: ['<%= srcPath %>/**/bin/Debug/*.dll', '<%= srcPath %>/**/bin/Debug/*.exe'] // Points to test dll
      }
    },

    nugetrestore: {
      restore: {
        src: '<%= srcPath %><%= solutionName %>',
        dest: 'packages/'
      }
    }

  });



  grunt.registerTask('default', ['build']);
  grunt.registerTask('build', ['nugetrestore','msbuild:release']);
  grunt.registerTask('test', ['nugetrestore','msbuild:debug', 'mstest']);
  grunt.registerTask('release', ['assemblyinfo', 'test']);
};

@@ -334,16 +334,66 @@
 e_here',
+%0A    testProjectPath: 'path_to_your_test_project',
 %0A%0A    //
@@ -1987,45 +1987,31 @@
  %25%3E/
-**/bin/Debug/*.dll', '%3C%25= src
+%3C%25= testProject
 Path %25%3E/
 **/b
@@ -2010,11 +2010,8 @@
  %25%3E/
-**/
 bin/
@@ -2022,11 +2022,11 @@
 g/*.
-exe
+dll
 '%5D /

test project path is configurable