Add .NET Standard build and align project structure
and style rules with cakebuild/cake
This commit is contained in:
parent
b43b2a19e4
commit
1f55b94d2a
13 changed files with 347 additions and 200 deletions
|
@ -1,16 +1,18 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using Cake.Core;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
namespace Cake.ArgumentHelpers.Tests {
|
||||
[TestFixture()]
|
||||
public class ArgumentOrEnvironmentVariableAlias_BoolTests {
|
||||
Mock<ICakeContext> cakeContextMock;
|
||||
Mock<ICakeArguments> cakeArgumentsMock;
|
||||
Mock<ICakeEnvironment> cakeEnvironmentMock;
|
||||
namespace Cake.ArgumentHelpers.Tests
|
||||
{
|
||||
public class ArgumentOrEnvironmentVariableAlias_BoolTests : IDisposable
|
||||
{
|
||||
private Mock<ICakeContext> cakeContextMock;
|
||||
private Mock<ICakeArguments> cakeArgumentsMock;
|
||||
private Mock<ICakeEnvironment> cakeEnvironmentMock;
|
||||
|
||||
[SetUp]
|
||||
public void Setup() {
|
||||
public ArgumentOrEnvironmentVariableAlias_BoolTests()
|
||||
{
|
||||
cakeContextMock = new Mock<ICakeContext>();
|
||||
cakeArgumentsMock = new Mock<ICakeArguments>();
|
||||
cakeEnvironmentMock = new Mock<ICakeEnvironment>();
|
||||
|
@ -18,17 +20,20 @@ namespace Cake.ArgumentHelpers.Tests {
|
|||
cakeContextMock.Setup(cakeContext => cakeContext.Environment).Returns(cakeEnvironmentMock.Object);
|
||||
}
|
||||
|
||||
void SetupVariables(string key, string environmentPrefix, bool? argumentValue, bool? environmentValue) {
|
||||
private void SetupVariables(string key, string environmentPrefix, bool? argumentValue, bool? environmentValue)
|
||||
{
|
||||
bool hasArgument = argumentValue != null;
|
||||
cakeArgumentsMock.Setup(x => x.HasArgument(key)).Returns(hasArgument);
|
||||
if (hasArgument) {
|
||||
if (hasArgument)
|
||||
{
|
||||
cakeArgumentsMock.Setup(x => x.GetArgument(key)).Returns(argumentValue.ToString());
|
||||
}
|
||||
cakeEnvironmentMock.Setup(x => x.GetEnvironmentVariable(environmentPrefix + key)).Returns(environmentValue != null ? environmentValue.Value.ToString() : null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TrueArgumentAndNullEnvironment_ReturnsTrue() {
|
||||
[Fact]
|
||||
public void TrueArgumentAndNullEnvironment_ReturnsTrue()
|
||||
{
|
||||
var testKey = "someVariable";
|
||||
var testKeyEnvironmentPrefix = "somePrefix_";
|
||||
bool? testArgumentValue = true;
|
||||
|
@ -39,10 +44,11 @@ namespace Cake.ArgumentHelpers.Tests {
|
|||
var expected = true;
|
||||
var actual = cakeContextMock.Object.ArgumentOrEnvironmentVariable(testKey, testKeyEnvironmentPrefix, true);
|
||||
|
||||
Assert.AreEqual(expected, actual, "Didn't find Argument variable.");
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
[Test]
|
||||
public void FalseArgumentAndNullEnvironment_ReturnsFalse() {
|
||||
[Fact]
|
||||
public void FalseArgumentAndNullEnvironment_ReturnsFalse()
|
||||
{
|
||||
var testKey = "someVariable";
|
||||
var testKeyEnvironmentPrefix = "somePrefix_";
|
||||
bool? testArgumentValue = false;
|
||||
|
@ -53,10 +59,11 @@ namespace Cake.ArgumentHelpers.Tests {
|
|||
var expected = false;
|
||||
var actual = cakeContextMock.Object.ArgumentOrEnvironmentVariable(testKey, testKeyEnvironmentPrefix, true);
|
||||
|
||||
Assert.AreEqual(expected, actual, "Didn't find Argument variable.");
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
[Test]
|
||||
public void NullArgumentAndTrueEnvironment_ReturnsTrue() {
|
||||
[Fact]
|
||||
public void NullArgumentAndTrueEnvironment_ReturnsTrue()
|
||||
{
|
||||
var testKey = "someVariable";
|
||||
var testKeyEnvironmentPrefix = "somePrefix_";
|
||||
bool? testArgumentValue = null;
|
||||
|
@ -67,10 +74,11 @@ namespace Cake.ArgumentHelpers.Tests {
|
|||
var expected = true;
|
||||
var actual = cakeContextMock.Object.ArgumentOrEnvironmentVariable(testKey, testKeyEnvironmentPrefix, true);
|
||||
|
||||
Assert.AreEqual(expected, actual, "Didn't find Environment variable.");
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
[Test]
|
||||
public void NullArgumentAndFalseEnvironment_ReturnsFalse() {
|
||||
[Fact]
|
||||
public void NullArgumentAndFalseEnvironment_ReturnsFalse()
|
||||
{
|
||||
var testKey = "someVariable";
|
||||
var testKeyEnvironmentPrefix = "somePrefix_";
|
||||
bool? testArgumentValue = null;
|
||||
|
@ -81,10 +89,11 @@ namespace Cake.ArgumentHelpers.Tests {
|
|||
var expected = false;
|
||||
var actual = cakeContextMock.Object.ArgumentOrEnvironmentVariable(testKey, testKeyEnvironmentPrefix, true);
|
||||
|
||||
Assert.AreEqual(expected, actual, "Didn't find Environment variable.");
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
[Test]
|
||||
public void NullArgumentAndTrueEnvironmentWithoutPrefix_ReturnsTrue() {
|
||||
[Fact]
|
||||
public void NullArgumentAndTrueEnvironmentWithoutPrefix_ReturnsTrue()
|
||||
{
|
||||
var testKey = "someVariable";
|
||||
var testKeyEnvironmentPrefix = (string)null;
|
||||
bool? testArgumentValue = null;
|
||||
|
@ -95,10 +104,11 @@ namespace Cake.ArgumentHelpers.Tests {
|
|||
var expected = true;
|
||||
var actual = cakeContextMock.Object.ArgumentOrEnvironmentVariable(testKey, testKeyEnvironmentPrefix, true);
|
||||
|
||||
Assert.AreEqual(expected, actual, "Didn't find Environment variable without prefix.");
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
[Test]
|
||||
public void NullArgumentAndTrueEnvironmentNoPrefixOverload_ReturnsTrue() {
|
||||
[Fact]
|
||||
public void NullArgumentAndTrueEnvironmentNoPrefixOverload_ReturnsTrue()
|
||||
{
|
||||
var testKey = "someVariable";
|
||||
var testKeyEnvironmentPrefix = (string)null;
|
||||
bool? testArgumentValue = null;
|
||||
|
@ -109,10 +119,11 @@ namespace Cake.ArgumentHelpers.Tests {
|
|||
var expected = true;
|
||||
var actual = cakeContextMock.Object.ArgumentOrEnvironmentVariable(testKey, true);
|
||||
|
||||
Assert.AreEqual(expected, actual, "Didn't find Environment variable without prefix.");
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
[Test]
|
||||
public void TrueArgumentAndTrueEnvironment_ReturnsTrue() {
|
||||
[Fact]
|
||||
public void TrueArgumentAndTrueEnvironment_ReturnsTrue()
|
||||
{
|
||||
var testKey = "someVariable";
|
||||
var testKeyEnvironmentPrefix = "somePrefix_";
|
||||
bool? testArgumentValue = true;
|
||||
|
@ -123,10 +134,11 @@ namespace Cake.ArgumentHelpers.Tests {
|
|||
var expected = true;
|
||||
var actual = cakeContextMock.Object.ArgumentOrEnvironmentVariable(testKey, testKeyEnvironmentPrefix, true);
|
||||
|
||||
Assert.AreEqual(expected, actual, "Didn't find variable value from either source.");
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
[Test]
|
||||
public void TrueArgumentAndFalseEnvironment_ReturnsTrue() {
|
||||
[Fact]
|
||||
public void TrueArgumentAndFalseEnvironment_ReturnsTrue()
|
||||
{
|
||||
var testKey = "someVariable";
|
||||
var testKeyEnvironmentPrefix = "somePrefix_";
|
||||
bool? testArgumentValue = true;
|
||||
|
@ -137,10 +149,11 @@ namespace Cake.ArgumentHelpers.Tests {
|
|||
var expected = true;
|
||||
var actual = cakeContextMock.Object.ArgumentOrEnvironmentVariable(testKey, testKeyEnvironmentPrefix, true);
|
||||
|
||||
Assert.AreEqual(expected, actual, "Explicit argument variable didn't override opposite environment variable.");
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
[Test]
|
||||
public void FalseArgumentAndTrueEnvironment_ReturnsFalse() {
|
||||
[Fact]
|
||||
public void FalseArgumentAndTrueEnvironment_ReturnsFalse()
|
||||
{
|
||||
var testKey = "someVariable";
|
||||
var testKeyEnvironmentPrefix = "somePrefix_";
|
||||
bool? testArgumentValue = false;
|
||||
|
@ -151,7 +164,11 @@ namespace Cake.ArgumentHelpers.Tests {
|
|||
var expected = false;
|
||||
var actual = cakeContextMock.Object.ArgumentOrEnvironmentVariable(testKey, testKeyEnvironmentPrefix, true);
|
||||
|
||||
Assert.AreEqual(expected, actual, "Explicit argument variable didn't override opposite environment variable.");
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using Cake.Core;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
namespace Cake.ArgumentHelpers.Tests {
|
||||
[TestFixture()]
|
||||
public class ArgumentOrEnvironmentVariableAlias_StringTests {
|
||||
Mock<ICakeContext> cakeContextMock;
|
||||
Mock<ICakeArguments> cakeArgumentsMock;
|
||||
Mock<ICakeEnvironment> cakeEnvironmentMock;
|
||||
namespace Cake.ArgumentHelpers.Tests
|
||||
{
|
||||
public class ArgumentOrEnvironmentVariableAlias_StringTests : IDisposable
|
||||
{
|
||||
private Mock<ICakeContext> cakeContextMock;
|
||||
private Mock<ICakeArguments> cakeArgumentsMock;
|
||||
private Mock<ICakeEnvironment> cakeEnvironmentMock;
|
||||
|
||||
[SetUp]
|
||||
public void Setup() {
|
||||
public ArgumentOrEnvironmentVariableAlias_StringTests()
|
||||
{
|
||||
cakeContextMock = new Mock<ICakeContext>();
|
||||
cakeArgumentsMock = new Mock<ICakeArguments>();
|
||||
cakeEnvironmentMock = new Mock<ICakeEnvironment>();
|
||||
|
@ -18,10 +20,12 @@ namespace Cake.ArgumentHelpers.Tests {
|
|||
cakeContextMock.Setup(cakeContext => cakeContext.Environment).Returns(cakeEnvironmentMock.Object);
|
||||
}
|
||||
|
||||
void SetupVariables(string key, string environmentPrefix, string argumentValue, string environmentValue) {
|
||||
private void SetupVariables(string key, string environmentPrefix, string argumentValue, string environmentValue)
|
||||
{
|
||||
bool hasArgument = argumentValue != null;
|
||||
cakeArgumentsMock.Setup(x => x.HasArgument(key)).Returns(hasArgument);
|
||||
if (hasArgument) {
|
||||
if (hasArgument)
|
||||
{
|
||||
cakeArgumentsMock.Setup(x => x.GetArgument(key)).Returns(argumentValue.ToString());
|
||||
}
|
||||
bool hasEnvironmentVariable = environmentValue != null;
|
||||
|
@ -31,8 +35,9 @@ namespace Cake.ArgumentHelpers.Tests {
|
|||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SomeArgumentAndNullEnvironment_ReturnsSome() {
|
||||
[Fact]
|
||||
public void SomeArgumentAndNullEnvironment_ReturnsSome()
|
||||
{
|
||||
var testKey = "someVariable";
|
||||
var testKeyEnvironmentPrefix = "somePrefix_";
|
||||
string testArgumentValue = "Some";
|
||||
|
@ -43,10 +48,11 @@ namespace Cake.ArgumentHelpers.Tests {
|
|||
var expected = testArgumentValue;
|
||||
var actual = cakeContextMock.Object.ArgumentOrEnvironmentVariable(testKey, testKeyEnvironmentPrefix, (string)null);
|
||||
|
||||
Assert.AreEqual(expected, actual, "Didn't find Argument variable.");
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
[Test]
|
||||
public void NullArgumentAndNullEnvironmentAndNullDefault_ReturnsNull() {
|
||||
[Fact]
|
||||
public void NullArgumentAndNullEnvironmentAndNullDefault_ReturnsNull()
|
||||
{
|
||||
var testKey = "someVariable";
|
||||
var testKeyEnvironmentPrefix = "somePrefix_";
|
||||
string testArgumentValue = null;
|
||||
|
@ -57,10 +63,11 @@ namespace Cake.ArgumentHelpers.Tests {
|
|||
var expected = (string)null;
|
||||
var actual = cakeContextMock.Object.ArgumentOrEnvironmentVariable(testKey, testKeyEnvironmentPrefix, (string)null);
|
||||
|
||||
Assert.AreEqual(expected, actual, "Found unexpected variable value.");
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
[Test]
|
||||
public void NullArgumentAndSomeEnvironment_ReturnsSome() {
|
||||
[Fact]
|
||||
public void NullArgumentAndSomeEnvironment_ReturnsSome()
|
||||
{
|
||||
var testKey = "someVariable";
|
||||
var testKeyEnvironmentPrefix = "somePrefix_";
|
||||
string testArgumentValue = null;
|
||||
|
@ -71,10 +78,11 @@ namespace Cake.ArgumentHelpers.Tests {
|
|||
var expected = testEnvironmentValue;
|
||||
var actual = cakeContextMock.Object.ArgumentOrEnvironmentVariable(testKey, testKeyEnvironmentPrefix, (string)null);
|
||||
|
||||
Assert.AreEqual(expected, actual, "Didn't find Environment variable.");
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
[Test]
|
||||
public void NullArgumentAndSomeEnvironmentWithoutPrefix_ReturnsSome() {
|
||||
[Fact]
|
||||
public void NullArgumentAndSomeEnvironmentWithoutPrefix_ReturnsSome()
|
||||
{
|
||||
var testKey = "someVariable";
|
||||
var testKeyEnvironmentPrefix = (string)null;
|
||||
string testArgumentValue = null;
|
||||
|
@ -85,10 +93,11 @@ namespace Cake.ArgumentHelpers.Tests {
|
|||
var expected = testEnvironmentValue;
|
||||
var actual = cakeContextMock.Object.ArgumentOrEnvironmentVariable(testKey, testKeyEnvironmentPrefix, (string)null);
|
||||
|
||||
Assert.AreEqual(expected, actual, "Didn't find Environment variable without prefix.");
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
[Test]
|
||||
public void SomeArgumentAndOtherEnvironment_ReturnsSome() {
|
||||
[Fact]
|
||||
public void SomeArgumentAndOtherEnvironment_ReturnsSome()
|
||||
{
|
||||
var testKey = "someVariable";
|
||||
var testKeyEnvironmentPrefix = "somePrefix_";
|
||||
string testArgumentValue = "Some";
|
||||
|
@ -99,9 +108,9 @@ namespace Cake.ArgumentHelpers.Tests {
|
|||
var expected = testArgumentValue;
|
||||
var actual = cakeContextMock.Object.ArgumentOrEnvironmentVariable(testKey, testKeyEnvironmentPrefix, (string)null);
|
||||
|
||||
Assert.AreEqual(expected, actual, "Didn't find correct variable value from Argument source.");
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
[Test]
|
||||
[Fact]
|
||||
public void NullArgumentAndNullEnvironment_ReturnsDefault()
|
||||
{
|
||||
var testKey = "someVariable";
|
||||
|
@ -115,9 +124,9 @@ namespace Cake.ArgumentHelpers.Tests {
|
|||
var expected = defaultValue;
|
||||
var actual = cakeContextMock.Object.ArgumentOrEnvironmentVariable(testKey, testKeyEnvironmentPrefix, defaultValue);
|
||||
|
||||
Assert.AreEqual(expected, actual, "Didn't fall back on default value.");
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
[Test]
|
||||
[Fact]
|
||||
public void NullArgumentAndNullEnvironmentWithoutDefault_ReturnsNull()
|
||||
{
|
||||
var testKey = "someVariable";
|
||||
|
@ -130,7 +139,11 @@ namespace Cake.ArgumentHelpers.Tests {
|
|||
var expected = (string)null;
|
||||
var actual = cakeContextMock.Object.ArgumentOrEnvironmentVariable(testKey, testKeyEnvironmentPrefix);
|
||||
|
||||
Assert.AreEqual(expected, actual, "Didn't fail to a null value.");
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,62 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{1297E243-9A95-45A5-A5C6-AAAC94ECEE22}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Cake.ArgumentHelpers.Tests</RootNamespace>
|
||||
<AssemblyName>Cake.ArgumentHelpers.Tests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
|
||||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
|
||||
<IsCakeTestProject>true</IsCakeTestProject>
|
||||
</PropertyGroup>
|
||||
<!-- Import shared functionality -->
|
||||
<Import Project="..\Shared.msbuild" />
|
||||
<!-- Project references -->
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Cake.ArgumentHelpers\Cake.ArgumentHelpers.csproj" />
|
||||
</ItemGroup>
|
||||
<!-- Global packages -->
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
|
||||
<PackageReference Include="xunit" Version="2.3.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
|
||||
<PackageReference Include="Castle.Core" Version="4.1.0" />
|
||||
<PackageReference Include="Moq" Version="4.7.63" />
|
||||
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
|
||||
</ItemGroup>
|
||||
<!-- .NET Framework packages -->
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
|
||||
<Reference Include="System" />
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath>..\packages\NUnit.3.7.1\lib\net45\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Cake.Core">
|
||||
<HintPath>..\packages\Cake.Core.0.21.0\lib\net45\Cake.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Cake.Common">
|
||||
<HintPath>..\packages\Cake.Common.0.21.0\lib\net45\Cake.Common.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Castle.Core">
|
||||
<HintPath>..\packages\Castle.Core.4.1.0\lib\net45\Castle.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Moq">
|
||||
<HintPath>..\packages\Moq.4.7.63\lib\net45\Moq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ArgumentOrEnvironmentVariableAlias_StringTests.cs" />
|
||||
<Compile Include="ArgumentOrEnvironmentVariableAlias_BoolTests.cs" />
|
||||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Cake.ArgumentHelpers\Cake.ArgumentHelpers.csproj">
|
||||
<Project>{9C50A7C4-E00D-4851-8311-81135D062C77}</Project>
|
||||
<Name>Cake.ArgumentHelpers</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Cake.Common" version="0.21.0" targetFramework="net461" />
|
||||
<package id="Cake.Core" version="0.21.0" targetFramework="net461" />
|
||||
<package id="Castle.Core" version="4.1.0" targetFramework="net461" />
|
||||
<package id="Moq" version="4.7.63" targetFramework="net461" />
|
||||
<package id="NUnit" version="3.7.1" targetFramework="net461" />
|
||||
</packages>
|
|
@ -1,53 +1,63 @@
|
|||
using System;
|
||||
using Cake.Common;
|
||||
using Cake.Core;
|
||||
using Cake.Core.Annotations;
|
||||
using Cake.Common;
|
||||
|
||||
namespace Cake.ArgumentHelpers {
|
||||
namespace Cake.ArgumentHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains Aliases for helping work with combinations of Argument and Environment variables.
|
||||
/// </summary>
|
||||
[CakeAliasCategory("Arguments")]
|
||||
[CakeAliasCategory("Environment")]
|
||||
public static class ArgumentOrEnvironmentVariableAlias {
|
||||
public static class ArgumentOrEnvironmentVariableAlias
|
||||
{
|
||||
/// <summary>
|
||||
/// Get a bool variable from various script inputs: first via Argument, then falling back on EnvironmentVariable, finally falling back on a default.
|
||||
/// </summary>
|
||||
/// <param name="context">Cake context</param>
|
||||
/// <param name="name">The argument name to attempt to find in the command line parameters, prefixing with <paramref name="environmentNamePrefix"/> to attempt to find in environment variables.</param>
|
||||
/// <param name="environmentNamePrefix">An optional prefix used to qualify the same variable name when present in EnvironmentVariable form (e.g., "MySetting" command-line argument vs. "MyTool_MySetting" environment variable).</param>
|
||||
/// <param name="defaultValue">The default value</param>
|
||||
/// <returns>Value found or default, first checked in command-line argument, then environment variable.</returns>
|
||||
[CakeMethodAlias]
|
||||
[CakeAliasCategory("Argument or environment variable")]
|
||||
public static bool ArgumentOrEnvironmentVariable(this ICakeContext context, string name, string environmentNamePrefix, bool defaultValue) {
|
||||
return ArgumentAliases.Argument(context, name, EnvironmentAliases.EnvironmentVariable(context, (environmentNamePrefix ?? "") + name) ?? defaultValue.ToString()).Equals("true", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
public static bool ArgumentOrEnvironmentVariable(this ICakeContext context, string name, string environmentNamePrefix, bool defaultValue) =>
|
||||
ArgumentAliases.Argument(context, name, EnvironmentAliases.EnvironmentVariable(context, (environmentNamePrefix ?? string.Empty) + name) ?? defaultValue.ToString()).Equals("true", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>
|
||||
/// Get a bool variable from various script inputs: first via Argument, then falling back on EnvironmentVariable, finally falling back on a default.
|
||||
/// </summary>
|
||||
/// <param name="context">Cake context</param>
|
||||
/// <param name="name">The argument name to attempt to find in either the command line parameters or environment variables.</param>
|
||||
/// <param name="defaultValue">The default value</param>
|
||||
/// <returns>Value found or default, first checked in command-line argument, then environment variable.</returns>
|
||||
[CakeMethodAlias]
|
||||
[CakeAliasCategory("Argument or environment variable")]
|
||||
public static bool ArgumentOrEnvironmentVariable(this ICakeContext context, string name, bool defaultValue) {
|
||||
public static bool ArgumentOrEnvironmentVariable(this ICakeContext context, string name, bool defaultValue)
|
||||
{
|
||||
return context.ArgumentOrEnvironmentVariable(name, null, defaultValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a string variable from various script inputs: first via Argument, then falling back on EnvironmentVariable, finally falling back on a default.
|
||||
/// </summary>
|
||||
/// <param name="context">Cake context</param>
|
||||
/// <param name="name">The argument name to attempt to find in the command line parameters, prefixing with <paramref name="environmentNamePrefix"/> to attempt to find in environment variables.</param>
|
||||
/// <param name="environmentNamePrefix">An optional prefix used to qualify the same variable name when present in EnvironmentVariable form (e.g., "MySetting" command-line argument vs. "MyTool_MySetting" environment variable).</param>
|
||||
/// <param name="defaultValue">The default value</param>
|
||||
/// <returns>Value found or default, first checked in command-line argument, then environment variable.</returns>
|
||||
[CakeMethodAlias]
|
||||
[CakeAliasCategory("Argument or environment variable")]
|
||||
public static string ArgumentOrEnvironmentVariable(this ICakeContext context, string name, string environmentNamePrefix, string defaultValue) {
|
||||
public static string ArgumentOrEnvironmentVariable(this ICakeContext context, string name, string environmentNamePrefix, string defaultValue)
|
||||
{
|
||||
return ArgumentAliases.Argument<string>(context, name, EnvironmentAliases.EnvironmentVariable(context, environmentNamePrefix + name)) ?? defaultValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a string variable from various script inputs: first via Argument, then falling back on EnvironmentVariable, finally falling back on a default.
|
||||
/// </summary>
|
||||
/// <param name="context">Cake context</param>
|
||||
/// <param name="name">The argument name to attempt to find in the command line parameters, prefixing with <paramref name="environmentNamePrefix"/> to attempt to find in environment variables.</param>
|
||||
/// <param name="environmentNamePrefix">An optional prefix used to qualify the same variable name when present in EnvironmentVariable form (e.g., "MySetting" command-line argument vs. "MyTool_MySetting" environment variable).</param>
|
||||
/// <returns>Value found or default, first checked in command-line argument, then environment variable.</returns>
|
||||
|
|
|
@ -1,37 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{9C50A7C4-E00D-4851-8311-81135D062C77}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Cake.ArgumentHelpers</RootNamespace>
|
||||
<AssemblyName>Cake.ArgumentHelpers</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
<TargetFrameworks>net46;netstandard2.0</TargetFrameworks>
|
||||
<OutputType>Library</OutputType>
|
||||
<PlatformTarget>AnyCpu</PlatformTarget>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>bin\Release\Cake.ArgumentHelpers.xml</DocumentationFile>
|
||||
<!-- Package specific metadata -->
|
||||
<PropertyGroup>
|
||||
<Description>Cake aliases (methods) to help with consuming arguments and environment variables.</Description>
|
||||
</PropertyGroup>
|
||||
<!-- Import shared functionality -->
|
||||
<Import Project="..\Shared.msbuild" />
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Cake.Core" Version="0.27.1" />
|
||||
<PackageReference Include="Cake.Common" Version="0.27.1" />
|
||||
</ItemGroup>
|
||||
<!-- .NET Core packages -->
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
|
||||
</ItemGroup>
|
||||
<!-- .NET Framework packages -->
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
|
@ -40,19 +30,5 @@
|
|||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Cake.Core">
|
||||
<HintPath>..\packages\Cake.Core.0.21.0\lib\net45\Cake.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Cake.Common">
|
||||
<HintPath>..\packages\Cake.Common.0.21.0\lib\net45\Cake.Common.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ArgumentOrEnvironmentVariableAlias.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -7,8 +7,6 @@ using System.Runtime.InteropServices;
|
|||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Cake.ArgumentHelpers")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Cake.ArgumentHelpers")]
|
||||
[assembly: AssemblyCopyright("Copyright 2017 © Adam Patridge")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Cake.Common" version="0.21.0" targetFramework="net45" />
|
||||
<package id="Cake.Core" version="0.21.0" targetFramework="net45" />
|
||||
<package id="NuGet.CommandLine" version="4.3.0" targetFramework="net45" developmentDependency="true" />
|
||||
</packages>
|
37
Cake.ruleset
Normal file
37
Cake.ruleset
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RuleSet Name="Cake Ruleset" ToolsVersion="12.0">
|
||||
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
|
||||
<Rule Id="AD0001" Action="None" /> <!-- Remove later -->
|
||||
<Rule Id="SA0001" Action="None" /> <!-- Remove later -->
|
||||
<Rule Id="SA1100" Action="None" />
|
||||
<Rule Id="SA1101" Action="None" />
|
||||
<Rule Id="SA1116" Action="None" />
|
||||
<Rule Id="SA1117" Action="None" />
|
||||
<Rule Id="SA1118" Action="None" />
|
||||
<Rule Id="SA1121" Action="None" />
|
||||
<Rule Id="SA1127" Action="None" />
|
||||
<Rule Id="SA1128" Action="None" />
|
||||
<Rule Id="SA1113" Action="None" /> <!-- Enable? -->
|
||||
<Rule Id="SA1139" Action="None" /> <!-- Enable? -->
|
||||
<Rule Id="SA1200" Action="None" />
|
||||
<Rule Id="SA1201" Action="None" />
|
||||
<Rule Id="SA1202" Action="None" />
|
||||
<Rule Id="SA1204" Action="None" />
|
||||
<Rule Id="SA1300" Action="None" />
|
||||
<Rule Id="SA1402" Action="None" />
|
||||
<Rule Id="SA1309" Action="None" />
|
||||
<Rule Id="SA1403" Action="None" />
|
||||
<Rule Id="SA1404" Action="None" />
|
||||
<Rule Id="SA1413" Action="None" /> <!-- Remove later -->
|
||||
<Rule Id="SA1513" Action="None" />
|
||||
<Rule Id="SA1515" Action="None" />
|
||||
<Rule Id="SA1516" Action="None" />
|
||||
<Rule Id="SA1600" Action="None" /> <!-- Remove later -->
|
||||
<Rule Id="SA1601" Action="None" /> <!-- Remove later -->
|
||||
<Rule Id="SA1602" Action="None" /> <!-- Remove later -->
|
||||
<Rule Id="SA1612" Action="None" /> <!-- Remove later -->
|
||||
<Rule Id="SA1625" Action="None" />
|
||||
<Rule Id="SA1633" Action="None" /> <!-- Remove later -->
|
||||
<Rule Id="SA1649" Action="None" />
|
||||
</Rules>
|
||||
</RuleSet>
|
57
Shared.msbuild
Normal file
57
Shared.msbuild
Normal file
|
@ -0,0 +1,57 @@
|
|||
<Project>
|
||||
<!-- General package metadata -->
|
||||
<PropertyGroup>
|
||||
<PackageId>$(AssemblyName)</PackageId>
|
||||
<Copyright>Copyright (c) .NET Foundation and contributors</Copyright>
|
||||
<Authors>Patrik Svensson, Mattias Karlsson, Gary Ewan Park, Alistair Chapman, Martin Björkström and contributors</Authors>
|
||||
<Company>Patrik Svensson, Mattias Karlsson, Gary Ewan Park, Alistair Chapman, Martin Björkström and contributors</Company>
|
||||
<PackageLicenseUrl>https://github.com/cake-build/cake/blob/develop/LICENSE</PackageLicenseUrl>
|
||||
<PackageIconUrl>https://raw.githubusercontent.com/cake-build/graphics/master/png/cake-medium.png</PackageIconUrl>
|
||||
<RepositoryUrl>https://github.com/cake-build/cake</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<PackageTags>Cake;Script;Build</PackageTags>
|
||||
</PropertyGroup>
|
||||
<!-- Misc -->
|
||||
<PropertyGroup>
|
||||
<NetStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">2.0.0</NetStandardImplicitPackageVersion>
|
||||
</PropertyGroup>
|
||||
<!-- Warnings as errors -->
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<!-- Define .NET Core constants -->
|
||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
|
||||
<DefineConstants>$(DefineConstants);NETCORE</DefineConstants>
|
||||
<DebugType>portable</DebugType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
|
||||
<DefineConstants>$(DefineConstants);NETCORE</DefineConstants>
|
||||
<DebugType>portable</DebugType>
|
||||
</PropertyGroup>
|
||||
<!-- Attribute generation -->
|
||||
<PropertyGroup>
|
||||
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
|
||||
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
|
||||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
||||
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
|
||||
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
|
||||
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
|
||||
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
|
||||
</PropertyGroup>
|
||||
<!-- StyleCop -->
|
||||
<PropertyGroup>
|
||||
<CodeAnalysisRuleSet Condition="$(IsCakeTestProject) == ''">$(MSBuildThisFileDirectory)Cake.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet Condition="$(IsCakeTestProject) == 'true'">$(MSBuildThisFileDirectory)Test.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition="$(IsCakeTestProject) == 'true'">
|
||||
<Content Include="$(MSBuildThisFileDirectory)xunit.runner.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta004">
|
||||
<PrivateAssets>All</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
49
Test.ruleset
Normal file
49
Test.ruleset
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RuleSet Name="Cake Ruleset" ToolsVersion="12.0">
|
||||
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
|
||||
<Rule Id="AD0001" Action="None" /> <!-- Remove later -->
|
||||
<Rule Id="SA0001" Action="None" /> <!-- Remove later -->
|
||||
<Rule Id="SA1100" Action="None" />
|
||||
<Rule Id="SA1101" Action="None" />
|
||||
<Rule Id="SA1113" Action="None" /> <!-- Enable? -->
|
||||
<Rule Id="SA1116" Action="None" />
|
||||
<Rule Id="SA1117" Action="None" />
|
||||
<Rule Id="SA1118" Action="None" />
|
||||
<Rule Id="SA1121" Action="None" />
|
||||
<Rule Id="SA1122" Action="None" />
|
||||
<Rule Id="SA1124" Action="None" />
|
||||
<Rule Id="SA1127" Action="None" />
|
||||
<Rule Id="SA1128" Action="None" />
|
||||
<Rule Id="SA1139" Action="None" /> <!-- Enable? -->
|
||||
<Rule Id="SA1200" Action="None" />
|
||||
<Rule Id="SA1201" Action="None" />
|
||||
<Rule Id="SA1202" Action="None" />
|
||||
<Rule Id="SA1204" Action="None" />
|
||||
<Rule Id="SA1300" Action="None" />
|
||||
<Rule Id="SA1306" Action="None" />
|
||||
<Rule Id="SA1310" Action="None" />
|
||||
<Rule Id="SA1402" Action="None" />
|
||||
<Rule Id="SA1309" Action="None" />
|
||||
<Rule Id="SA1403" Action="None" />
|
||||
<Rule Id="SA1404" Action="None" />
|
||||
<Rule Id="SA1405" Action="None" />
|
||||
<Rule Id="SA1413" Action="None" /> <!-- Remove later -->
|
||||
<Rule Id="SA1513" Action="None" />
|
||||
<Rule Id="SA1515" Action="None" />
|
||||
<Rule Id="SA1516" Action="None" />
|
||||
<Rule Id="SA1600" Action="None" /> <!-- Remove later -->
|
||||
<Rule Id="SA1601" Action="None" /> <!-- Remove later -->
|
||||
<Rule Id="SA1602" Action="None" /> <!-- Remove later -->
|
||||
<Rule Id="SA1612" Action="None" /> <!-- Remove later -->
|
||||
<Rule Id="SA1625" Action="None" />
|
||||
<Rule Id="SA1633" Action="None" /> <!-- Remove later -->
|
||||
<Rule Id="SA1649" Action="None" />
|
||||
<Rule Id="SA1652" Action="None" />
|
||||
<Rule Id="xUnit1012" Action="None" /> <!-- Remove later -->
|
||||
<Rule Id="xUnit1013" Action="None" /> <!-- Remove later -->
|
||||
<Rule Id="xUnit2000" Action="None" /> <!-- Remove later -->
|
||||
<Rule Id="xUnit2002" Action="None" /> <!-- Remove later -->
|
||||
<Rule Id="xUnit2003" Action="None" /> <!-- Remove later -->
|
||||
<Rule Id="xUnit2004" Action="None" /> <!-- Remove later -->
|
||||
</Rules>
|
||||
</RuleSet>
|
32
stylecop.json
Normal file
32
stylecop.json
Normal file
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
|
||||
"settings": {
|
||||
"indentation": {
|
||||
"useTabs": false,
|
||||
"indentationSize": 4
|
||||
},
|
||||
"documentationRules": {
|
||||
"documentExposedElements": true,
|
||||
"documentInternalElements": false,
|
||||
"documentPrivateElements": false,
|
||||
"documentInterfaces": true,
|
||||
"documentPrivateFields": false
|
||||
},
|
||||
"layoutRules": {
|
||||
"newlineAtEndOfFile": "allow"
|
||||
},
|
||||
"maintainabilityRules": {
|
||||
},
|
||||
"orderingRules": {
|
||||
"usingDirectivesPlacement": "outsideNamespace",
|
||||
"systemUsingDirectivesFirst": true,
|
||||
"elementOrder": [
|
||||
"kind",
|
||||
"accessibility",
|
||||
"constant",
|
||||
"static",
|
||||
"readonly"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
1
xunit.runner.json
Normal file
1
xunit.runner.json
Normal file
|
@ -0,0 +1 @@
|
|||
{ "appDomain": "denied" }
|
Loading…
Add table
Reference in a new issue