Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<clear />
<add key="nugetbuild" value="https://www.myget.org/F/nugetbuild/api/v3/index.json" />
<add key="dotnet-buildtools" value="https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json" />
<!-- 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 -->
<add key="dotnet-core-test" value="https://dotnet.myget.org/F/dotnet-core-test/api/v3/index.json" />
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
4 changes: 3 additions & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ $env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1

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

dotnet build3 $RepoRoot\core-sdk.sln /nologo /m /p:Configuration=$Configuration /p:Platform=$Platform
# TODO: https://github.com/dotnet/sdk/issues/13 add back `/m` when the MSBuild hang is fixed
dotnet build3 $RepoRoot\core-sdk.sln /nologo /p:Configuration=$Configuration /p:Platform=$Platform

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the ci builds, is there any reason for us to build a different platform, or should we just leave it as is?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build fails without setting this property. I'm not sure if it is because our .sln file is configured incorrectly or not.

Feel free to fix it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because you don't have a default set in the targets. Usually this lives in the project file itself, but as part of the cleanup we'll pull it out into a targets.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the error I get when I don't set this property:

F:\core-sdk\core-sdk.sln.metaproj : error MSB4126: The specified solution configuration "Debug|x64" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the default solution configuration. [F:\core-sdk\core-sdk.sln]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it is a problem with dotnet build3. See https://github.com/dotnet/cli/blob/feature/msbuild/src/dotnet/commands/dotnet-build3/MSBuildForwardingApp.cs#L41

It is explicitly setting the current architecture as the Platform. That's why this is failing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it set some form of default platform? What is the alternative here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the alternative here is that the .csproj (or the Sdk .props/.targets) declares its default. And the tool running MSBuild doesn't specify it.

if($LASTEXITCODE -ne 0) { throw "Failed to build" }
7 changes: 7 additions & 0 deletions core-sdk.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
build.ps1 = build.ps1
EndProjectSection
EndProject
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}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -23,11 +25,16 @@ Global
{DF7D2697-B3B4-45C2-8297-27245F528A99}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DF7D2697-B3B4-45C2-8297-27245F528A99}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DF7D2697-B3B4-45C2-8297-27245F528A99}.Release|Any CPU.Build.0 = Release|Any CPU
{6A698C1D-F604-4295-B6FC-7FC726F9FE5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6A698C1D-F604-4295-B6FC-7FC726F9FE5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6A698C1D-F604-4295-B6FC-7FC726F9FE5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6A698C1D-F604-4295-B6FC-7FC726F9FE5F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{DF7D2697-B3B4-45C2-8297-27245F528A99} = {1FEED16D-E07D-47C1-BB4C-56CD9F42B53B}
{6A698C1D-F604-4295-B6FC-7FC726F9FE5F} = {1FEED16D-E07D-47C1-BB4C-56CD9F42B53B}
EndGlobalSection
EndGlobal
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);
}
}
}
}
}
}
}
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>
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")]
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": ""
}
}
}
Loading