forked from dotnet/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request dotnet#8 from eerhardt/FillUpTasks
Port GenerateDepsFile and GenerateRuntimeConfigurationFiles
- Loading branch information
Showing
22 changed files
with
14,371 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/Tasks/Microsoft.DotNet.Core.Build.Tasks.UnitTests/GivenADependencyContextBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System.IO; | ||
using FluentAssertions.Json; | ||
using Microsoft.Extensions.DependencyModel; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using NuGet.Common; | ||
using NuGet.Frameworks; | ||
using NuGet.ProjectModel; | ||
using Xunit; | ||
|
||
namespace Microsoft.DotNet.Core.Build.Tasks.UnitTests | ||
{ | ||
public class GivenADependencyContextBuilder | ||
{ | ||
/// <summary> | ||
/// Tests that DependencyContextBuilder generates DependencyContexts correctly. | ||
/// </summary> | ||
[Theory] | ||
[InlineData("dotnet.new", "1.0.0")] | ||
[InlineData("simple.dependencies", "1.0.0")] | ||
public void ItBuildsDependencyContextsFromProjectLockFiles(string mainProjectName, string mainProjectVersion) | ||
{ | ||
LockFile lockFile = LockFileUtilities.GetLockFile($"{mainProjectName}.project.lock.json", NullLogger.Instance); | ||
|
||
DependencyContext dependencyContext = new DependencyContextBuilder().Build( | ||
mainProjectName, | ||
mainProjectVersion, | ||
compilerOptions: null, | ||
lockFile: lockFile, | ||
framework: FrameworkConstants.CommonFrameworks.NetCoreApp10, | ||
runtime: null); | ||
|
||
JObject result = Save(dependencyContext); | ||
JObject baseline = ReadJson($"{mainProjectName}.deps.json"); | ||
|
||
baseline | ||
.Should() | ||
.BeEquivalentTo(result); | ||
} | ||
|
||
private static JObject ReadJson(string path) | ||
{ | ||
using (JsonTextReader jsonReader = new JsonTextReader(File.OpenText(path))) | ||
{ | ||
JsonSerializer serializer = new JsonSerializer(); | ||
return serializer.Deserialize<JObject>(jsonReader); | ||
} | ||
} | ||
|
||
private JObject Save(DependencyContext dependencyContext) | ||
{ | ||
using (var memoryStream = new MemoryStream()) | ||
{ | ||
new DependencyContextWriter().Write(dependencyContext, memoryStream); | ||
using (var readStream = new MemoryStream(memoryStream.ToArray())) | ||
{ | ||
using (var textReader = new StreamReader(readStream)) | ||
{ | ||
using (var reader = new JsonTextReader(textReader)) | ||
{ | ||
return JObject.Load(reader); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...soft.DotNet.Core.Build.Tasks.UnitTests/Microsoft.DotNet.Core.Build.Tasks.UnitTests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<Import Project="..\Microsoft.DotNet.Core.Build.Tasks\Microsoft.DotNet.Core.Sdk.props" /> | ||
<Import Project="..\..\..\build\Targets\Settings.targets" /> | ||
<PropertyGroup> | ||
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion> | ||
<ProjectGuid>{6A698C1D-F604-4295-B6FC-7FC726F9FE5F}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Microsoft.DotNet.Core.Build.Tasks.UnitTests</RootNamespace> | ||
<AssemblyName>Microsoft.DotNet.Core.Build.Tasks.UnitTests</AssemblyName> | ||
<DefaultLanguage>en-US</DefaultLanguage> | ||
<TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier> | ||
<TargetFrameworkVersion>v1.3</TargetFrameworkVersion> | ||
<OutDir>$(OutDir)Tests\</OutDir> | ||
<GenerateDependencyFile>false</GenerateDependencyFile> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="GivenADependencyContextBuilder.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="dotnet.new.deps.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Include="dotnet.new.project.lock.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Include="project.json" /> | ||
<None Include="simple.dependencies.deps.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Include="simple.dependencies.project.lock.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Microsoft.DotNet.Core.Build.Tasks\Microsoft.DotNet.Core.Build.Tasks.csproj"> | ||
<Project>{df7d2697-b3b4-45c2-8297-27245f528a99}</Project> | ||
<Name>Microsoft.DotNet.Core.Build.Tasks</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<Import Project="..\Microsoft.DotNet.Core.Build.Tasks\Microsoft.DotNet.Core.Sdk.targets" /> | ||
</Project> |
28 changes: 28 additions & 0 deletions
28
src/Tasks/Microsoft.DotNet.Core.Build.Tasks.UnitTests/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Reflection; | ||
using System.Resources; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("Microsoft.DotNet.Core.Build.Tasks.UnitTests")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("Microsoft.DotNet.Core.Build.Tasks.UnitTests")] | ||
[assembly: AssemblyCopyright("Copyright © 2016")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
[assembly: NeutralResourcesLanguage("en")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
23 changes: 23 additions & 0 deletions
23
src/Tasks/Microsoft.DotNet.Core.Build.Tasks.UnitTests/dotnet.new.deps.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"runtimeTarget": { | ||
"name": ".NETCoreApp,Version=v1.0", | ||
"signature": "da39a3ee5e6b4b0d3255bfef95601890afd80709" | ||
}, | ||
"compilationOptions": {}, | ||
"targets": { | ||
".NETCoreApp,Version=v1.0": { | ||
"dotnet.new/1.0.0": { | ||
"runtime": { | ||
"dotnet.new.dll": {} | ||
} | ||
} | ||
} | ||
}, | ||
"libraries": { | ||
"dotnet.new/1.0.0": { | ||
"type": "project", | ||
"serviceable": false, | ||
"sha512": "" | ||
} | ||
} | ||
} |
Oops, something went wrong.