Skip to content

Commit

Permalink
added pack as msbuild target
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohit Agrawal committed Sep 8, 2016
1 parent cbdc164 commit 9b899f5
Show file tree
Hide file tree
Showing 38 changed files with 1,954 additions and 183 deletions.
7 changes: 7 additions & 0 deletions NuGet.Core.sln
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "NuGet.Commands.Test.Utility
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "NuGet.DependencyResolver.Core.Tests.Utility", "test\NuGet.Core.Tests\NuGet.DependencyResolver.Core.Tests.Utility\NuGet.DependencyResolver.Core.Tests.Utility.xproj", "{23C35C81-55E5-4E21-9E67-CCDEE901072B}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "NuGet.Build.Tasks.Pack", "src\NuGet.Core\NuGet.Build.Tasks.Pack\NuGet.Build.Tasks.Pack.xproj", "{E1E473C5-2954-45E4-AF95-287B506B696D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -372,6 +374,10 @@ Global
{23C35C81-55E5-4E21-9E67-CCDEE901072B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{23C35C81-55E5-4E21-9E67-CCDEE901072B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23C35C81-55E5-4E21-9E67-CCDEE901072B}.Release|Any CPU.Build.0 = Release|Any CPU
{E1E473C5-2954-45E4-AF95-287B506B696D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E1E473C5-2954-45E4-AF95-287B506B696D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E1E473C5-2954-45E4-AF95-287B506B696D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E1E473C5-2954-45E4-AF95-287B506B696D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -434,5 +440,6 @@ Global
{93D1D30C-45F8-4DCE-8EAD-7C7C504713B6} = {7323F93B-D141-4001-BB9E-7AF14031143E}
{975924FA-3B4F-46AD-AA3B-F7C066D3955C} = {7323F93B-D141-4001-BB9E-7AF14031143E}
{23C35C81-55E5-4E21-9E67-CCDEE901072B} = {7323F93B-D141-4001-BB9E-7AF14031143E}
{E1E473C5-2954-45E4-AF95-287B506B696D} = {BD1946CE-5544-4F28-A04A-9C3D51113E1A}
EndGlobalSection
EndGlobal
10 changes: 5 additions & 5 deletions src/NuGet.Clients/NuGet.CommandLine/Commands/ProjectFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public Common.ILogger Logger
}

[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "We want to continue regardless of any error we encounter extracting metadata.")]
public Packaging.PackageBuilder CreateBuilder(string basePath, NuGetVersion version, string suffix, bool buildIfNeeded)
public Packaging.PackageBuilder CreateBuilder(string basePath, NuGetVersion version, string suffix, bool buildIfNeeded, Packaging.PackageBuilder builder =null)
{
if (buildIfNeeded)
{
Expand All @@ -200,7 +200,7 @@ public Packaging.PackageBuilder CreateBuilder(string basePath, NuGetVersion vers
Path.GetFullPath(Path.GetDirectoryName(TargetPath))));
}

var builder = new Packaging.PackageBuilder();
builder = new Packaging.PackageBuilder();

try
{
Expand Down Expand Up @@ -883,7 +883,7 @@ private void ProcessDependencies(Packaging.PackageBuilder builder)
var i = 0;
foreach (var group in builder.DependencyGroups.ToList())
{
List<Packaging.Core.PackageDependency> newPackagesList = new List<Packaging.Core.PackageDependency>(group.Packages);
ISet<Packaging.Core.PackageDependency> newPackagesList = new HashSet<Packaging.Core.PackageDependency>(group.Packages);
foreach (var dependency in dependencies)
{
if (!newPackagesList.Contains(dependency.Value))
Expand All @@ -902,7 +902,7 @@ private void ProcessDependencies(Packaging.PackageBuilder builder)
}
else
{
builder.DependencyGroups.Add(new PackageDependencyGroup(NuGetFramework.AnyFramework, dependencies.Values));
builder.DependencyGroups.Add(new PackageDependencyGroup(NuGetFramework.AnyFramework, new HashSet<Packaging.Core.PackageDependency>(dependencies.Values)));
}
}
}
Expand All @@ -913,7 +913,7 @@ private void ProcessDependencies(Packaging.PackageBuilder builder)
builder.DependencyGroups.Clear();

// REVIEW: IS NuGetFramework.AnyFramework correct?
builder.DependencyGroups.Add(new PackageDependencyGroup(NuGetFramework.AnyFramework, dependencies.Values));
builder.DependencyGroups.Add(new PackageDependencyGroup(NuGetFramework.AnyFramework, new HashSet<Packaging.Core.PackageDependency>(dependencies.Values)));
}
}

Expand Down
60 changes: 60 additions & 0 deletions src/NuGet.Core/NuGet.Build.Tasks.Pack/MSBuildLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NuGet.Common;

namespace NuGet.Build.Tasks.Pack
{
/// <summary>
/// TaskLoggingHelper -> ILogger
/// </summary>
internal class MSBuildLogger : Common.ILogger
{
private readonly TaskLoggingHelper _taskLogging;

public MSBuildLogger(TaskLoggingHelper taskLogging)
{
_taskLogging = taskLogging;
}

public void LogDebug(string data)
{
_taskLogging.LogMessage(MessageImportance.Low, data);
}

public void LogError(string data)
{
// Log errors as warnings. Then log the error summary as actual errors.
LogWarning(data);
}

public void LogErrorSummary(string data)
{
_taskLogging.LogMessage(MessageImportance.High, data);
}

public void LogInformation(string data)
{
_taskLogging.LogMessage(MessageImportance.Normal, data);
}

public void LogInformationSummary(string data)
{
LogInformation(data);
}

public void LogMinimal(string data)
{
_taskLogging.LogMessage(MessageImportance.High, data);
}

public void LogVerbose(string data)
{
_taskLogging.LogMessage(MessageImportance.Low, data);
}

public void LogWarning(string data)
{
_taskLogging.LogWarning(data);
}
}
}
21 changes: 21 additions & 0 deletions src/NuGet.Core/NuGet.Build.Tasks.Pack/NuGet.Build.Tasks.Pack.xproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>

<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>e1e473c5-2954-45e4-af95-287b506b696d</ProjectGuid>
<RootNamespace>NuGet.Build.Tasks.Pack</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
</PropertyGroup>

<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
Loading

0 comments on commit 9b899f5

Please sign in to comment.