Added support for Nuget and MSTest #14

Closed
wants to merge 18 commits into
from
+667 −32
Split
View
@@ -0,0 +1,105 @@
+<Configuration>
+ <CodeStyleSettings>
+ <ExternalPath IsNull="False">
+ </ExternalPath>
+ <Sharing>SOLUTION</Sharing>
+ <CSS>
+ <FormatSettings />
+ <Naming2 />
+ </CSS>
+ <CSharp>
+ <FormatSettings>
+ <ANONYMOUS_METHOD_DECLARATION_BRACES>END_OF_LINE</ANONYMOUS_METHOD_DECLARATION_BRACES>
+ <CASE_BLOCK_BRACES>END_OF_LINE</CASE_BLOCK_BRACES>
+ <EXPLICIT_PRIVATE_MODIFIER>False</EXPLICIT_PRIVATE_MODIFIER>
+ <INITIALIZER_BRACES>END_OF_LINE</INITIALIZER_BRACES>
+ <INVOCABLE_DECLARATION_BRACES>END_OF_LINE</INVOCABLE_DECLARATION_BRACES>
+ <MODIFIERS_ORDER IsNull="False">
+ <Item>public</Item>
+ <Item>protected</Item>
+ <Item>internal</Item>
+ <Item>private</Item>
+ <Item>new</Item>
+ <Item>abstract</Item>
+ <Item>virtual</Item>
+ <Item>override</Item>
+ <Item>sealed</Item>
+ <Item>static</Item>
+ <Item>readonly</Item>
+ <Item>extern</Item>
+ <Item>unsafe</Item>
+ <Item>volatile</Item>
+ </MODIFIERS_ORDER>
+ <OTHER_BRACES>END_OF_LINE</OTHER_BRACES>
+ <PLACE_FIELD_ATTRIBUTE_ON_SAME_LINE>False</PLACE_FIELD_ATTRIBUTE_ON_SAME_LINE>
+ <TYPE_DECLARATION_BRACES>END_OF_LINE</TYPE_DECLARATION_BRACES>
+ <WRAP_LINES>False</WRAP_LINES>
+ </FormatSettings>
+ <UsingsSettings>
+ <AddImportsToDeepestScope>True</AddImportsToDeepestScope>
+ </UsingsSettings>
+ <Naming2>
+ <EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
+ <EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
+ </Naming2>
+ </CSharp>
+ <HTML>
+ <FormatSettings />
+ </HTML>
+ <JavaScript>
+ <FormatSettings />
+ <Naming2 />
+ </JavaScript>
+ <VB>
+ <FormatSettings>
+ <WRAP_LINES>False</WRAP_LINES>
+ </FormatSettings>
+ <ImportsSettings />
+ <Naming2>
+ <EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
+ <EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
+ </Naming2>
+ </VB>
+ <Web>
+ <Naming2 />
+ </Web>
+ <XML>
+ <FormatSettings />
+ </XML>
+ <Xaml>
+ <Naming2 />
+ </Xaml>
+ <FileHeader Region="License"><![CDATA[Copyright Jeremy Skinner (http://www.jeremyskinner.co.uk) and Contributors
+
+Licensed under the Microsoft Public License. You may
+obtain a copy of the license at:
+
+http://www.microsoft.com/opensource/licenses.mspx
+
+By using this source code in any fashion, you are agreeing
+to be bound by the terms of the Microsoft Public License.
+
+You must not remove this notice, or any other, from this software.]]></FileHeader>
+ <GenerateMemberBody />
+ <Naming2>
+ <EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
+ <EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
+ <PredefinedRule Inspect="False" Prefix="" Suffix="" Style="AaBb" ElementKind="MethodPropertyEvent" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="TypesAndNamespaces" />
+ <PredefinedRule Inspect="True" Prefix="I" Suffix="" Style="AaBb" ElementKind="Interfaces" />
+ <PredefinedRule Inspect="True" Prefix="T" Suffix="" Style="AaBb" ElementKind="TypeParameters" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Locals" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="LocalConstants" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Parameters" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PublicFields" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="PrivateInstanceFields" />
+ <PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateStaticFields" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Constants" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateConstants" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="StaticReadonly" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="PrivateStaticReadonly" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="EnumMember" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Other" />
+ </Naming2>
+ </CodeStyleSettings>
+</Configuration>
View
Binary file not shown.
@@ -25,7 +25,7 @@ public abstract class ExecutableTool<T> : IRunnable<T> where T : ExecutableTool<
protected abstract void Execute();
protected void Execute(string args) {
- if (! File.Exists(toolPath)) {
+ if (!File.Exists(toolPath)) {
throw new FileNotFoundException(string.Format("Could not execute the file '{0}' as it does not exist.", toolPath));
}
@@ -0,0 +1,63 @@
+#region License
+
+// Copyright Jeremy Skinner (http://www.jeremyskinner.co.uk) and Contributors
+//
+// Licensed under the Microsoft Public License. You may
+// obtain a copy of the license at:
+//
+// http://www.microsoft.com/opensource/licenses.mspx
+//
+// By using this source code in any fashion, you are agreeing
+// to be bound by the terms of the Microsoft Public License.
+//
+// You must not remove this notice, or any other, from this software.
+
+#endregion
+
+namespace Phantom.Core.Builtins {
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Linq;
+ using System.Text;
+
+ public class mstest : TestRunner<mstest> {
+ readonly StringBuilder args;
+
+ public mstest() {
+ args = new StringBuilder();
+ toolPath = FindToolPath();
+ }
+
+ public string[] options { get; set; }
+ public string[] tests { get; set; }
+
+ protected override void Execute() {
+ foreach (var container in assemblies) {
+ args.AppendFormat(" /testcontainer:\"{0}\"", container);
+ }
+
+ if (tests != null && tests.Length != 0) {
+ foreach (var test in tests) {
+ args.AppendFormat(" /test:{0}", test);
+ }
+ }
+
+ if (options != null && options.Length != 0) {
+ args.Append(string.Join(" ", options));
+ }
+
+ Execute(args.ToString());
+ }
+
+ private string FindToolPath() {
+ var defaultPaths = new List<string> {
+ @"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe",
+ @"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe",
+ @"C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\mstest.exe",
+ @"C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\mstest.exe"
+ };
+
+ return defaultPaths.FirstOrDefault(File.Exists);
+ }
+ }
+}
@@ -15,13 +15,13 @@
#endregion
namespace Phantom.Core.Builtins {
- using System;
using System.Collections.Generic;
+ using System.Text;
/// <summary>
/// NUnit integration
/// </summary>
- public class nunit : ExecutableTool<nunit> {
+ public class nunit : TestRunner<nunit> {
public nunit() {
toolPath = "lib/nunit/nunit-console.exe";
teamCityArgs = "v2.0 x86 NUnit-2.4.6";
@@ -31,24 +31,13 @@ public class nunit : ExecutableTool<nunit> {
public string exclude { get; set; }
public bool enableTeamCity { get; set; }
public string teamCityArgs { get; set; }
- public string[] assemblies { get; set; }
- public string assembly { get; set; }
string GetTeamCityNunitLancherPath() {
return UtilityFunctions.env("teamcity.dotnet.nunitlauncher");
}
protected override void Execute() {
- if ((assemblies == null || assemblies.Length == 0) && string.IsNullOrEmpty(assembly)) {
- throw new InvalidOperationException("Please specify either the 'assembly' or the 'assemblies' property when calling 'nunit'");
- }
-
- //single assembly takes precedence.
- if (!string.IsNullOrEmpty(assembly)) {
- assemblies = new[] {assembly};
- }
-
- var args = new System.Collections.Generic.List<string>();
+ var args = new List<string>();
if (enableTeamCity) {
string teamcityLauncherPath = GetTeamCityNunitLancherPath();
@@ -80,9 +69,7 @@ public class nunit : ExecutableTool<nunit> {
}
foreach (var asm in assemblies) {
- var nunitArgs = new List<string>(args) {
- asm
- };
+ var nunitArgs = new List<string>(args) {string.Concat("\"", asm, "\"")};
Execute(nunitArgs.JoinWith(" "));
}
@@ -0,0 +1,68 @@
+#region License
+
+// Copyright Jeremy Skinner (http://www.jeremyskinner.co.uk) and Contributors
+//
+// Licensed under the Microsoft Public License. You may
+// obtain a copy of the license at:
+//
+// http://www.microsoft.com/opensource/licenses.mspx
+//
+// By using this source code in any fashion, you are agreeing
+// to be bound by the terms of the Microsoft Public License.
+//
+// You must not remove this notice, or any other, from this software.
+
+#endregion
+
+namespace Phantom.Core.Builtins {
+ using System;
+ using System.IO;
+ using System.Text;
+
+ public class nuget_pack : ExecutableTool<nuget_pack> {
+ readonly StringBuilder nugetArgs;
+
+ public nuget_pack() {
+ nugetArgs = new StringBuilder();
+ }
+
+ public string nuspecFile { get; set; }
+ public string basePath { get; set; }
+ public string outputDirectory { get; set; }
+ public string version { get; set; }
+ public bool symbols { get; set; }
+ public bool verbose { get; set; }
+
+ protected override void Execute() {
+ if (string.IsNullOrWhiteSpace(nuspecFile)) {
+ throw new InvalidOperationException("Nuspec file to pack must be specified.");
+ }
+ nugetArgs.AppendFormat("pack \"{0}\"", Path.GetFullPath(nuspecFile));
+
+ if (string.IsNullOrWhiteSpace(basePath)) {
+ basePath = Environment.CurrentDirectory;
+ }
+ nugetArgs.AppendFormat(" -basePath \"{0}\"", Path.GetFullPath(basePath));
+
+ if (!string.IsNullOrWhiteSpace(outputDirectory)) {
+ outputDirectory = Path.GetFullPath(outputDirectory);
+ nugetArgs.AppendFormat(" -outputDirectory \"{0}\"", outputDirectory);
+ IOFunctions.mkdir(outputDirectory);
+ }
+
+ if (!string.IsNullOrWhiteSpace(version)) {
+ nugetArgs.AppendFormat(" -version \"{0}\"", version);
+ }
+
+ if (symbols) {
+ nugetArgs.Append(" -symbols");
+ }
+
+ if (verbose) {
+ nugetArgs.Append(" -verbose");
+ }
+
+ Execute(nugetArgs.ToString());
+ }
+ }
+}
@@ -0,0 +1,55 @@
+#region License
+
+// Copyright Jeremy Skinner (http://www.jeremyskinner.co.uk) and Contributors
+//
+// Licensed under the Microsoft Public License. You may
+// obtain a copy of the license at:
+//
+// http://www.microsoft.com/opensource/licenses.mspx
+//
+// By using this source code in any fashion, you are agreeing
+// to be bound by the terms of the Microsoft Public License.
+//
+// You must not remove this notice, or any other, from this software.
+
+#endregion
+
+namespace Phantom.Core.Builtins {
+ using System;
+ using System.Text;
+
+ public class nuget_publish : ExecutableTool<nuget_publish> {
+ readonly StringBuilder nugetArgs;
+
+ public nuget_publish() {
+ nugetArgs = new StringBuilder();
+ }
+
+ public string id { get; set; }
+ public string version { get; set; }
+ public string apiKey { get; set; }
+ public string source { get; set; }
+
+ protected override void Execute() {
+ if (string.IsNullOrWhiteSpace(id)) {
+ throw new InvalidOperationException("Nuget package id is required when publishing a package.");
+ }
+
+ if (string.IsNullOrWhiteSpace(version)) {
+ throw new InvalidOperationException("Nuget package version is required when publishing a package.");
+ }
+
+ if (string.IsNullOrWhiteSpace(apiKey)) {
+ throw new InvalidOperationException("Nuget api key is required when publishing a package.");
+ }
+
+ nugetArgs.AppendFormat("publish {0} {1} {2}", id, version, apiKey);
+
+ if (!string.IsNullOrWhiteSpace(source)) {
+ nugetArgs.AppendFormat(" -source {0}", source);
+ }
+
+ Execute(nugetArgs.ToString());
+ }
+ }
+}
Oops, something went wrong.