Repository navigation
Port GenerateDepsFile and GenerateRuntimeConfigurationFiles #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
85ce425
Port GenerateDepsFile and GenerateRuntimeConfigurationFiles
eerhardt 2d3aa66
Add incremental build support to GenerateDependencyFile and GenerateR…
eerhardt 0c009c6
Add tests for the DependencyContextBuilder.
eerhardt b73011e
Fix LockFileCache to use IBuildEngine4.RegisterTaskObject to cache th…
eerhardt eaa9577
Add copyright and warning to MSBuild files.
eerhardt 66c930c
Add tracking issues for TODOs.
eerhardt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
There was a problem hiding this comment.
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#L41It is explicitly setting the current architecture as the
Platform. That's why this is failing.There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.