Skip to content

Commit

Permalink
Seed with the source and tests from Visual Studio 2015 Update 1
Browse files Browse the repository at this point in the history
This is the source that shipped in Visual Studio 2015 Update 1, with
the following changes:

- It's been pulled out of our internal build system into a standalone
  repository. As a result, a few assembly-level attributes of the built
  binaries will differ.
- The source files were rearranged a bit.
- Copyright headers have been updated.
- The tests have been upgraded to use xUnit 2.1.
  • Loading branch information
dotnet-bot authored and jasonmalinowski committed Jan 12, 2016
0 parents commit 2c1f0a9
Show file tree
Hide file tree
Showing 49 changed files with 58,096 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
* text=auto encoding=UTF-8

*.cs text diff=csharp
*.csproj text
*.props text
*.targets text
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.vs
bin/
obj/
*.user
project.lock.json
*.nuget.props
*.nuget.targets
14 changes: 14 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
NuGet.BuildTasks

Copyright (c) .NET Foundation. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use
these files except in compliance with the License. You may obtain a copy of the
License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
28 changes: 28 additions & 0 deletions NuGet.BuildTasks.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.NuGet.Build.Tasks", "src\Microsoft.NuGet.Build.Tasks\Microsoft.NuGet.Build.Tasks.csproj", "{55DC2BBF-42AE-4BE8-A6E0-351EEF51C0FC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.NuGet.Build.Tasks.Tests", "src\Microsoft.NuGet.Build.Tasks.Tests\Microsoft.NuGet.Build.Tasks.Tests.csproj", "{61443D47-85B6-4519-96C1-2704BDF604BF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{55DC2BBF-42AE-4BE8-A6E0-351EEF51C0FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{55DC2BBF-42AE-4BE8-A6E0-351EEF51C0FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{55DC2BBF-42AE-4BE8-A6E0-351EEF51C0FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{55DC2BBF-42AE-4BE8-A6E0-351EEF51C0FC}.Release|Any CPU.Build.0 = Release|Any CPU
{61443D47-85B6-4519-96C1-2704BDF604BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{61443D47-85B6-4519-96C1-2704BDF604BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{61443D47-85B6-4519-96C1-2704BDF604BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{61443D47-85B6-4519-96C1-2704BDF604BF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
13 changes: 13 additions & 0 deletions ThirdPartyNotices.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This project uses or incorporates third party material from the projects listed below. The original copyright notice and the license under which Microsoft received such third party material are set forth below. Microsoft reserves all other rights not expressly granted, whether by implication, estoppel or otherwise.

Newtonsoft.Json 6.0.4

The MIT License

Copyright (c) 2007 James Newton-King

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Binary file added build/PublicKey.snk
Binary file not shown.
36 changes: 36 additions & 0 deletions src/Microsoft.NuGet.Build.Tasks.Tests/AnalyzerResolutionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Linq;
using Xunit;
using static System.Text.Encoding;

namespace Microsoft.NuGet.Build.Tasks.Tests
{
public class AnalyzerResolutionTests
{
[Fact]
public static void TestAnalyzerResolutionCSharp()
{
var result = NuGetTestHelpers.ResolvePackagesWithJsonFileContents(
Default.GetString(Json.Json.analyzers),
targetMoniker: ".NETCore,Version=v5.0",
runtimeIdentifier: "",
projectLanguage: "C#");

AssertHelpers.AssertCountOf(8, result.Analyzers);
}

[Fact]
public static void TestAnalyzerResolutionVisualBasic()
{
var result = NuGetTestHelpers.ResolvePackagesWithJsonFileContents(
Default.GetString(Json.Json.analyzers),
targetMoniker: ".NETCore,Version=v5.0",
runtimeIdentifier: "",
projectLanguage: "vb");

AssertHelpers.AssertCountOf(8, result.Analyzers);
}
}
}
55 changes: 55 additions & 0 deletions src/Microsoft.NuGet.Build.Tasks.Tests/AssertHelpers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Build.Framework;
using Xunit;

namespace Microsoft.NuGet.Build.Tasks.Tests
{
internal static class AssertHelpers
{
public static void AssertCountOf(int expectedCount, IEnumerable<ITaskItem> items)
{
Assert.True(items.Count() == expectedCount,
$"Expected {expectedCount} items, but actually got {items.Count()} items:" + Environment.NewLine + string.Join(Environment.NewLine, items.Select(i => i.ItemSpec)));
}

public static void AssertNoTargetPaths(IEnumerable<ITaskItem> items)
{
foreach (var item in items)
{
Assert.Equal("", item.GetMetadata("DestinationSubDirectory"));
Assert.Equal("", item.GetMetadata("TargetPath"));
}
}

public static void AssertConsistentTargetPaths(IEnumerable<ITaskItem> items)
{
var mapToItem = new Dictionary<string, ITaskItem>(StringComparer.OrdinalIgnoreCase);

foreach (var item in items)
{
string effectiveTargetPath = item.GetMetadata("TargetPath");

if (string.IsNullOrEmpty(effectiveTargetPath))
{
effectiveTargetPath = Path.GetFileName(item.ItemSpec);
}

ITaskItem conflictingItem;
if (mapToItem.TryGetValue(effectiveTargetPath, out conflictingItem))
{
Assert.True(conflictingItem == null, $"Item {item.ItemSpec} and {conflictingItem.ItemSpec} have the same TargetPath.");
}

mapToItem.Add(effectiveTargetPath, item);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.IO;

namespace Microsoft.NuGet.Build.Tasks.Tests.Helpers
{
public sealed class DisposableDirectory : TempDirectory, IDisposable
{
public DisposableDirectory(TempRoot root)
: base(root)
{
}

public void Dispose()
{
if (Path != null && Directory.Exists(Path))
{
Directory.Delete(Path, recursive: true);
}
}
}
}
31 changes: 31 additions & 0 deletions src/Microsoft.NuGet.Build.Tasks.Tests/Helpers/DisposableFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.IO;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;

namespace Microsoft.NuGet.Build.Tasks.Tests.Helpers
{
public sealed class DisposableFile : TempFile, IDisposable
{
public DisposableFile(string path)
: base(path)
{
}

public DisposableFile(TempRoot root, string prefix = null, string extension = null, string directory = null, string callerSourcePath = null, int callerLineNumber = 0)
: base(root, prefix, extension, directory, callerSourcePath, callerLineNumber)
{
}

public void Dispose()
{
if (Path != null && File.Exists(Path))
{
File.Delete(Path);
}
}
}
}
89 changes: 89 additions & 0 deletions src/Microsoft.NuGet.Build.Tasks.Tests/Helpers/MockBuildEngine.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Build.Framework;

namespace Microsoft.NuGet.Build.Tasks.Tests.Helpers
{
public class MockBuildEngine : IBuildEngine, IBuildEngine2, IBuildEngine3, IBuildEngine4
{
public MockBuildEngine(TextWriter output)
{
this.Output = output;
}

private TextWriter Output { get; }

int IBuildEngine.ColumnNumberOfTaskNode => -1;

bool IBuildEngine.ContinueOnError => false;

int IBuildEngine.LineNumberOfTaskNode => -1;

string IBuildEngine.ProjectFileOfTaskNode => "this.xml";

bool IBuildEngine2.IsRunningMultipleNodes => false;

bool IBuildEngine.BuildProjectFile(string projectFileName, string[] targetNames, IDictionary globalProperties, IDictionary targetOutputs) => true;

void IBuildEngine.LogCustomEvent(CustomBuildEventArgs e)
{
this.Output.WriteLine($"Custom: {e.Message}");
}

void IBuildEngine.LogErrorEvent(BuildErrorEventArgs e)
{
this.Output.WriteLine($"Error: {e.Message}");
}

void IBuildEngine.LogMessageEvent(BuildMessageEventArgs e)
{
this.Output.WriteLine($"Message: {e.Message}");
}

void IBuildEngine.LogWarningEvent(BuildWarningEventArgs e)
{
this.Output.WriteLine($"Warning: {e.Message}");
}

private Dictionary<object, object> Tasks = new Dictionary<object, object>();

void IBuildEngine4.RegisterTaskObject(object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection)
{
Tasks.Add(key, obj);
}

object IBuildEngine4.GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime)
{
return null;
}

object IBuildEngine4.UnregisterTaskObject(object key, RegisteredTaskObjectLifetime lifetime)
{
var obj = Tasks[key];
Tasks.Remove(key);
return obj;
}

BuildEngineResult IBuildEngine3.BuildProjectFilesInParallel(string[] projectFileNames, string[] targetNames, IDictionary[] globalProperties, IList<string>[] removeGlobalProperties, string[] toolsVersion, bool returnTargetOutputs)
{
throw new NotImplementedException();
}

void IBuildEngine3.Yield() { }

void IBuildEngine3.Reacquire() { }

bool IBuildEngine2.BuildProjectFile(string projectFileName, string[] targetNames, IDictionary globalProperties, IDictionary targetOutputs, string toolsVersion) => true;

bool IBuildEngine2.BuildProjectFilesInParallel(string[] projectFileNames, string[] targetNames, IDictionary[] globalProperties, IDictionary[] targetOutputsPerProject, string[] toolsVersion, bool useResultsCache, bool unloadProjectsOnCompletion) => true;
}
}
Loading

0 comments on commit 2c1f0a9

Please sign in to comment.