Skip to content

Commit b113c4d

Browse files
authored
Merge pull request #8 from eerhardt/FillUpTasks
Port GenerateDepsFile and GenerateRuntimeConfigurationFiles
2 parents 195a19f + 66c930c commit b113c4d

22 files changed

+14371
-2
lines changed

NuGet.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
<clear />
66
<add key="nugetbuild" value="https://www.myget.org/F/nugetbuild/api/v3/index.json" />
77
<add key="dotnet-buildtools" value="https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json" />
8+
<!-- TODO: https://github.com/dotnet/sdk/issues/14 dotnet-core-test needs to be changed to dotnet-core once the netstandard1.3 DependencyModel package is available -->
9+
<add key="dotnet-core-test" value="https://dotnet.myget.org/F/dotnet-core-test/api/v3/index.json" />
810
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
911
</packageSources>
1012
</configuration>

build.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ $env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
4848
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
4949

5050
dotnet restore $RepoRoot
51+
if($LASTEXITCODE -ne 0) { throw "Failed to restore" }
5152

52-
dotnet build3 $RepoRoot\core-sdk.sln /nologo /m /p:Configuration=$Configuration /p:Platform=$Platform
53+
# TODO: https://github.com/dotnet/sdk/issues/13 add back `/m` when the MSBuild hang is fixed
54+
dotnet build3 $RepoRoot\core-sdk.sln /nologo /p:Configuration=$Configuration /p:Platform=$Platform
5355
if($LASTEXITCODE -ne 0) { throw "Failed to build" }

core-sdk.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1313
build.ps1 = build.ps1
1414
EndProjectSection
1515
EndProject
16+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.DotNet.Core.Build.Tasks.UnitTests", "src\Tasks\Microsoft.DotNet.Core.Build.Tasks.UnitTests\Microsoft.DotNet.Core.Build.Tasks.UnitTests.csproj", "{6A698C1D-F604-4295-B6FC-7FC726F9FE5F}"
17+
EndProject
1618
Global
1719
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1820
Debug|Any CPU = Debug|Any CPU
@@ -23,11 +25,16 @@ Global
2325
{DF7D2697-B3B4-45C2-8297-27245F528A99}.Debug|Any CPU.Build.0 = Debug|Any CPU
2426
{DF7D2697-B3B4-45C2-8297-27245F528A99}.Release|Any CPU.ActiveCfg = Release|Any CPU
2527
{DF7D2697-B3B4-45C2-8297-27245F528A99}.Release|Any CPU.Build.0 = Release|Any CPU
28+
{6A698C1D-F604-4295-B6FC-7FC726F9FE5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29+
{6A698C1D-F604-4295-B6FC-7FC726F9FE5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
30+
{6A698C1D-F604-4295-B6FC-7FC726F9FE5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{6A698C1D-F604-4295-B6FC-7FC726F9FE5F}.Release|Any CPU.Build.0 = Release|Any CPU
2632
EndGlobalSection
2733
GlobalSection(SolutionProperties) = preSolution
2834
HideSolutionNode = FALSE
2935
EndGlobalSection
3036
GlobalSection(NestedProjects) = preSolution
3137
{DF7D2697-B3B4-45C2-8297-27245F528A99} = {1FEED16D-E07D-47C1-BB4C-56CD9F42B53B}
38+
{6A698C1D-F604-4295-B6FC-7FC726F9FE5F} = {1FEED16D-E07D-47C1-BB4C-56CD9F42B53B}
3239
EndGlobalSection
3340
EndGlobal
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Copyright (c) .NET Foundation and contributors. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System.IO;
5+
using FluentAssertions.Json;
6+
using Microsoft.Extensions.DependencyModel;
7+
using Newtonsoft.Json;
8+
using Newtonsoft.Json.Linq;
9+
using NuGet.Common;
10+
using NuGet.Frameworks;
11+
using NuGet.ProjectModel;
12+
using Xunit;
13+
14+
namespace Microsoft.DotNet.Core.Build.Tasks.UnitTests
15+
{
16+
public class GivenADependencyContextBuilder
17+
{
18+
/// <summary>
19+
/// Tests that DependencyContextBuilder generates DependencyContexts correctly.
20+
/// </summary>
21+
[Theory]
22+
[InlineData("dotnet.new", "1.0.0")]
23+
[InlineData("simple.dependencies", "1.0.0")]
24+
public void ItBuildsDependencyContextsFromProjectLockFiles(string mainProjectName, string mainProjectVersion)
25+
{
26+
LockFile lockFile = LockFileUtilities.GetLockFile($"{mainProjectName}.project.lock.json", NullLogger.Instance);
27+
28+
DependencyContext dependencyContext = new DependencyContextBuilder().Build(
29+
mainProjectName,
30+
mainProjectVersion,
31+
compilerOptions: null,
32+
lockFile: lockFile,
33+
framework: FrameworkConstants.CommonFrameworks.NetCoreApp10,
34+
runtime: null);
35+
36+
JObject result = Save(dependencyContext);
37+
JObject baseline = ReadJson($"{mainProjectName}.deps.json");
38+
39+
baseline
40+
.Should()
41+
.BeEquivalentTo(result);
42+
}
43+
44+
private static JObject ReadJson(string path)
45+
{
46+
using (JsonTextReader jsonReader = new JsonTextReader(File.OpenText(path)))
47+
{
48+
JsonSerializer serializer = new JsonSerializer();
49+
return serializer.Deserialize<JObject>(jsonReader);
50+
}
51+
}
52+
53+
private JObject Save(DependencyContext dependencyContext)
54+
{
55+
using (var memoryStream = new MemoryStream())
56+
{
57+
new DependencyContextWriter().Write(dependencyContext, memoryStream);
58+
using (var readStream = new MemoryStream(memoryStream.ToArray()))
59+
{
60+
using (var textReader = new StreamReader(readStream))
61+
{
62+
using (var reader = new JsonTextReader(textReader))
63+
{
64+
return JObject.Load(reader);
65+
}
66+
}
67+
}
68+
}
69+
}
70+
}
71+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<Import Project="..\Microsoft.DotNet.Core.Build.Tasks\Microsoft.DotNet.Core.Sdk.props" />
5+
<Import Project="..\..\..\build\Targets\Settings.targets" />
6+
<PropertyGroup>
7+
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
8+
<ProjectGuid>{6A698C1D-F604-4295-B6FC-7FC726F9FE5F}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>Microsoft.DotNet.Core.Build.Tasks.UnitTests</RootNamespace>
12+
<AssemblyName>Microsoft.DotNet.Core.Build.Tasks.UnitTests</AssemblyName>
13+
<DefaultLanguage>en-US</DefaultLanguage>
14+
<TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier>
15+
<TargetFrameworkVersion>v1.3</TargetFrameworkVersion>
16+
<OutDir>$(OutDir)Tests\</OutDir>
17+
<GenerateDependencyFile>false</GenerateDependencyFile>
18+
</PropertyGroup>
19+
<ItemGroup>
20+
<Compile Include="GivenADependencyContextBuilder.cs" />
21+
<Compile Include="Properties\AssemblyInfo.cs" />
22+
</ItemGroup>
23+
<ItemGroup>
24+
<None Include="dotnet.new.deps.json">
25+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
26+
</None>
27+
<None Include="dotnet.new.project.lock.json">
28+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
29+
</None>
30+
<None Include="project.json" />
31+
<None Include="simple.dependencies.deps.json">
32+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
33+
</None>
34+
<None Include="simple.dependencies.project.lock.json">
35+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
36+
</None>
37+
</ItemGroup>
38+
<ItemGroup>
39+
<ProjectReference Include="..\Microsoft.DotNet.Core.Build.Tasks\Microsoft.DotNet.Core.Build.Tasks.csproj">
40+
<Project>{df7d2697-b3b4-45c2-8297-27245f528a99}</Project>
41+
<Name>Microsoft.DotNet.Core.Build.Tasks</Name>
42+
</ProjectReference>
43+
</ItemGroup>
44+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
45+
<Import Project="..\Microsoft.DotNet.Core.Build.Tasks\Microsoft.DotNet.Core.Sdk.targets" />
46+
</Project>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Reflection;
2+
using System.Resources;
3+
4+
// General Information about an assembly is controlled through the following
5+
// set of attributes. Change these attribute values to modify the information
6+
// associated with an assembly.
7+
[assembly: AssemblyTitle("Microsoft.DotNet.Core.Build.Tasks.UnitTests")]
8+
[assembly: AssemblyDescription("")]
9+
[assembly: AssemblyConfiguration("")]
10+
[assembly: AssemblyCompany("")]
11+
[assembly: AssemblyProduct("Microsoft.DotNet.Core.Build.Tasks.UnitTests")]
12+
[assembly: AssemblyCopyright("Copyright © 2016")]
13+
[assembly: AssemblyTrademark("")]
14+
[assembly: AssemblyCulture("")]
15+
[assembly: NeutralResourcesLanguage("en")]
16+
17+
// Version information for an assembly consists of the following four values:
18+
//
19+
// Major Version
20+
// Minor Version
21+
// Build Number
22+
// Revision
23+
//
24+
// You can specify all the values or you can default the Build and Revision Numbers
25+
// by using the '*' as shown below:
26+
// [assembly: AssemblyVersion("1.0.*")]
27+
[assembly: AssemblyVersion("1.0.0.0")]
28+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"runtimeTarget": {
3+
"name": ".NETCoreApp,Version=v1.0",
4+
"signature": "da39a3ee5e6b4b0d3255bfef95601890afd80709"
5+
},
6+
"compilationOptions": {},
7+
"targets": {
8+
".NETCoreApp,Version=v1.0": {
9+
"dotnet.new/1.0.0": {
10+
"runtime": {
11+
"dotnet.new.dll": {}
12+
}
13+
}
14+
}
15+
},
16+
"libraries": {
17+
"dotnet.new/1.0.0": {
18+
"type": "project",
19+
"serviceable": false,
20+
"sha512": ""
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)