From 457feacf9e04aea27259b76951ce211f1f3c8411 Mon Sep 17 00:00:00 2001 From: William Rall Date: Fri, 16 Sep 2022 15:29:56 -0700 Subject: [PATCH 1/7] Initial change to try to get project references that are not a part of the restore to be included in deps.json --- .../AuxLibrary/AuxLibrary.csproj | 58 +++++++++ .../AuxLibrary/Helper.cs | 15 +++ .../MainLibrary/Helper.cs | 16 +++ .../MainLibrary/MainLibrary.csproj | 61 ++++++++++ .../TestApp/Program.cs | 16 +++ .../TestApp/TestApp.csproj | 10 ++ .../GivenADependencyContextBuilder.cs | 9 +- .../DependencyContextBuilder.cs | 4 +- .../GenerateDepsFile.cs | 34 +++--- .../ReferenceInfo.cs | 28 ++++- ...ildAnAppWithTransitiveNonSdkProjectRefs.cs | 113 ++++++++++++++++++ ...ntToBuildAnAppWithTransitiveProjectRefs.cs | 4 +- 12 files changed, 337 insertions(+), 31 deletions(-) create mode 100644 src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/AuxLibrary/AuxLibrary.csproj create mode 100644 src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/AuxLibrary/Helper.cs create mode 100644 src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/MainLibrary/Helper.cs create mode 100644 src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/MainLibrary/MainLibrary.csproj create mode 100644 src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/TestApp/Program.cs create mode 100644 src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/TestApp/TestApp.csproj create mode 100644 src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveNonSdkProjectRefs.cs diff --git a/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/AuxLibrary/AuxLibrary.csproj b/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/AuxLibrary/AuxLibrary.csproj new file mode 100644 index 000000000000..b7fdb1b2e28c --- /dev/null +++ b/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/AuxLibrary/AuxLibrary.csproj @@ -0,0 +1,58 @@ + + + + + Debug + AnyCPU + 9a8d9cf9-379b-45c1-a95a-482ecb76a56c + Library + Properties + $(MSBuildProjectName) + $(MSBuildProjectName) + v4.6.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/AuxLibrary/Helper.cs b/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/AuxLibrary/Helper.cs new file mode 100644 index 000000000000..65b9edb1719e --- /dev/null +++ b/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/AuxLibrary/Helper.cs @@ -0,0 +1,15 @@ +// 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; + +namespace AuxLibrary +{ + public static class Helper + { + public static void WriteMessage() + { + Console.WriteLine("This string came from AuxLibrary!"); + } + } +} diff --git a/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/MainLibrary/Helper.cs b/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/MainLibrary/Helper.cs new file mode 100644 index 000000000000..f7f089c2d817 --- /dev/null +++ b/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/MainLibrary/Helper.cs @@ -0,0 +1,16 @@ +// 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; + +namespace MainLibrary +{ + public static class Helper + { + public static void WriteMessage() + { + Console.WriteLine("This string came from MainLibrary!"); + AuxLibrary.Helper.WriteMessage(); + } + } +} diff --git a/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/MainLibrary/MainLibrary.csproj b/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/MainLibrary/MainLibrary.csproj new file mode 100644 index 000000000000..69b9e61f4bea --- /dev/null +++ b/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/MainLibrary/MainLibrary.csproj @@ -0,0 +1,61 @@ + + + + + Debug + AnyCPU + a60a2336-1e2d-4c7a-85cb-a9e890e2558b + Library + Properties + $(MSBuildProjectName) + $(MSBuildProjectName) + v4.6.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/TestApp/Program.cs b/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/TestApp/Program.cs new file mode 100644 index 000000000000..b803e73560bd --- /dev/null +++ b/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/TestApp/Program.cs @@ -0,0 +1,16 @@ +// 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; + +namespace TestApp +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine("TestApp --depends on--> MainLibrary --depends on--> AuxLibrary"); + MainLibrary.Helper.WriteMessage(); + } + } +} diff --git a/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/TestApp/TestApp.csproj b/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/TestApp/TestApp.csproj new file mode 100644 index 000000000000..bb9d5646f68f --- /dev/null +++ b/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/TestApp/TestApp.csproj @@ -0,0 +1,10 @@ + + + Exe + $(CurrentTargetFramework) + false + + + + + \ No newline at end of file diff --git a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenADependencyContextBuilder.cs b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenADependencyContextBuilder.cs index 31b3bee2408c..b3a13c52492f 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenADependencyContextBuilder.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenADependencyContextBuilder.cs @@ -40,6 +40,7 @@ public void ItBuildsDependencyContextsFromProjectLockFiles( object[] resolvedNuGetFiles) { LockFile lockFile = TestLockFiles.GetLockFile(mainProjectName); + LockFileLookup lockFileLookup = new LockFileLookup(lockFile); SingleProjectInfo mainProject = SingleProjectInfo.Create( "/usr/Path", @@ -52,7 +53,7 @@ public void ItBuildsDependencyContextsFromProjectLockFiles( ReferenceInfo.CreateDirectReferenceInfos( referencePaths ?? new ITaskItem[] { }, referenceSatellitePaths ?? new ITaskItem[] { }, - projectContextHasProjectReferences: false, + lockFileLookup: lockFileLookup, i => true); ProjectContext projectContext = lockFile.CreateProjectContext( @@ -67,7 +68,7 @@ public void ItBuildsDependencyContextsFromProjectLockFiles( resolvedNuGetFiles = Array.Empty(); } - DependencyContext dependencyContext = new DependencyContextBuilder(mainProject, includeRuntimeFileVersions: false, runtimeGraph: null, projectContext: projectContext) + DependencyContext dependencyContext = new DependencyContextBuilder(mainProject, includeRuntimeFileVersions: false, runtimeGraph: null, projectContext: projectContext, libraryLookup: lockFileLookup) .WithDirectReferences(directReferences) .WithCompilationOptions(compilationOptions) .WithResolvedNuGetFiles((ResolvedFile[]) resolvedNuGetFiles) @@ -264,7 +265,7 @@ private DependencyContext BuildDependencyContextWithReferenceAssemblies(bool use useCompilationOptions ? CreateCompilationOptions() : null; - DependencyContext dependencyContext = new DependencyContextBuilder(mainProject, includeRuntimeFileVersions: false, runtimeGraph: null, projectContext: projectContext) + DependencyContext dependencyContext = new DependencyContextBuilder(mainProject, includeRuntimeFileVersions: false, runtimeGraph: null, projectContext: projectContext, libraryLookup: new LockFileLookup(lockFile)) .WithReferenceAssemblies(ReferenceInfo.CreateReferenceInfos(referencePaths)) .WithCompilationOptions(compilationOptions) .Build(); @@ -325,7 +326,7 @@ public void ItCanGenerateTheRuntimeFallbackGraph() void CheckRuntimeFallbacks(string runtimeIdentifier, int fallbackCount) { projectContext.LockFileTarget.RuntimeIdentifier = runtimeIdentifier; - var dependencyContextBuilder = new DependencyContextBuilder(mainProject, includeRuntimeFileVersions: false, runtimeGraph, projectContext); + var dependencyContextBuilder = new DependencyContextBuilder(mainProject, includeRuntimeFileVersions: false, runtimeGraph, projectContext, libraryLookup: new LockFileLookup(lockFile)); var runtimeFallbacks = dependencyContextBuilder.Build().RuntimeGraph; runtimeFallbacks diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/DependencyContextBuilder.cs b/src/Tasks/Microsoft.NET.Build.Tasks/DependencyContextBuilder.cs index 5428145aa35f..bbbaeb68ba98 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/DependencyContextBuilder.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/DependencyContextBuilder.cs @@ -47,14 +47,12 @@ internal class DependencyContextBuilder private const string NetCorePlatformLibrary = "Microsoft.NETCore.App"; - public DependencyContextBuilder(SingleProjectInfo mainProjectInfo, bool includeRuntimeFileVersions, RuntimeGraph runtimeGraph, ProjectContext projectContext) + public DependencyContextBuilder(SingleProjectInfo mainProjectInfo, bool includeRuntimeFileVersions, RuntimeGraph runtimeGraph, ProjectContext projectContext, LockFileLookup libraryLookup) { _mainProjectInfo = mainProjectInfo; _includeRuntimeFileVersions = includeRuntimeFileVersions; _runtimeGraph = runtimeGraph; - var libraryLookup = new LockFileLookup(projectContext.LockFile); - _dependencyLibraries = projectContext.LockFileTarget.Libraries .Select(lockFileTargetLibrary => { diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs index 67369ee412eb..ec0584c4162f 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs @@ -125,20 +125,19 @@ private Dictionary GetFilteredPackages() private void WriteDepsFile(string depsFilePath) { - ProjectContext projectContext; - if (AssetsFilePath == null) - { - projectContext = null; - } - else + ProjectContext projectContext = null; + LockFileLookup lockFileLookup = null; + if (AssetsFilePath != null) { LockFile lockFile = new LockFileCache(this).GetLockFile(AssetsFilePath); projectContext = lockFile.CreateProjectContext( - TargetFramework, - RuntimeIdentifier, - PlatformLibraryName, - RuntimeFrameworks, - IsSelfContained); + TargetFramework, + RuntimeIdentifier, + PlatformLibraryName, + RuntimeFrameworks, + IsSelfContained); + + lockFileLookup = new LockFileLookup(lockFile); } CompilationOptions compilationOptions = CompilationOptionsConverter.ConvertFrom(CompilerOptions); @@ -156,13 +155,14 @@ private void WriteDepsFile(string depsFilePath) IEnumerable referenceAssemblyInfos = ReferenceInfo.CreateReferenceInfos(ReferenceAssemblies); - // If there is a generated asset file. The projectContext will have project reference. - // So remove it from directReferences to avoid duplication - var projectContextHasProjectReferences = projectContext != null; + // If there is a generated asset file. The projectContext will have most project references. + // So remove any project reference contained within projectContext from directReferences to avoid duplication IEnumerable directReferences = - ReferenceInfo.CreateDirectReferenceInfos(ReferencePaths, + ReferenceInfo.CreateDirectReferenceInfos( + ReferencePaths, ReferenceSatellitePaths, - projectContextHasProjectReferences, isUserRuntimeAssembly); + lockFileLookup, + isUserRuntimeAssembly); IEnumerable dependencyReferences = ReferenceInfo.CreateDependencyReferenceInfos(ReferenceDependencyPaths, ReferenceSatellitePaths, isUserRuntimeAssembly); @@ -210,7 +210,7 @@ bool ShouldIncludeRuntimeAsset(ITaskItem item) RuntimeGraph runtimeGraph = IsSelfContained ? new RuntimeGraphCache(this).GetRuntimeGraph(RuntimeGraphPath) : null; - builder = new DependencyContextBuilder(mainProject, IncludeRuntimeFileVersions, runtimeGraph, projectContext); + builder = new DependencyContextBuilder(mainProject, IncludeRuntimeFileVersions, runtimeGraph, projectContext, lockFileLookup); } else { diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/ReferenceInfo.cs b/src/Tasks/Microsoft.NET.Build.Tasks/ReferenceInfo.cs index dfe0866df067..7736a43eea22 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/ReferenceInfo.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/ReferenceInfo.cs @@ -54,17 +54,33 @@ public static IEnumerable CreateReferenceInfos(IEnumerable CreateDirectReferenceInfos( IEnumerable referencePaths, IEnumerable referenceSatellitePaths, - bool projectContextHasProjectReferences, + LockFileLookup lockFileLookup, Func isRuntimeAssembly) { - - bool filterOutProjectReferenceIfInProjectContextAlready(ITaskItem referencePath) + bool lockFileContainsProject(ITaskItem referencePath) { - return (projectContextHasProjectReferences ? !IsProjectReference(referencePath) : true); + if (lockFileLookup == null) + { + return false; + } + + if (!IsProjectReference(referencePath)) + { + return false; + } + + string outputName = Path.GetFileName(referencePath.ItemSpec); + string projectName = Path.GetFileNameWithoutExtension(outputName); + if (string.IsNullOrEmpty(projectName)) + { + return true; + } + + return lockFileLookup.GetProject(projectName) != null; } IEnumerable directReferencePaths = referencePaths - .Where(r => filterOutProjectReferenceIfInProjectContextAlready(r) && !IsNuGetReference(r) && isRuntimeAssembly(r)); + .Where(r => !lockFileContainsProject(r) && !IsNuGetReference(r) && isRuntimeAssembly(r)); return CreateFilteredReferenceInfos(directReferencePaths, referenceSatellitePaths); } @@ -147,7 +163,7 @@ private static string GetVersion(ITaskItem referencePath) if (!string.IsNullOrEmpty(fusionName)) { AssemblyName assemblyName = new AssemblyName(fusionName); - version = assemblyName.Version.ToString(); + version = assemblyName.Version?.ToString(); } if (string.IsNullOrEmpty(version)) diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveNonSdkProjectRefs.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveNonSdkProjectRefs.cs new file mode 100644 index 000000000000..fed0e50dd911 --- /dev/null +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveNonSdkProjectRefs.cs @@ -0,0 +1,113 @@ +// 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.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; +using Microsoft.DotNet.Cli.Utils; +using Microsoft.NET.TestFramework; +using Microsoft.NET.TestFramework.Assertions; +using Microsoft.NET.TestFramework.Commands; +using Xunit; +using FluentAssertions; +using System.Xml.Linq; +using System.Linq; +using System; +using Xunit.Abstractions; +using Microsoft.Extensions.DependencyModel; + +namespace Microsoft.NET.Build.Tests +{ + public class GivenThatWeWantToBuildAnAppWithTransitiveNonSdkProjectRefs : SdkTest + { + public GivenThatWeWantToBuildAnAppWithTransitiveNonSdkProjectRefs(ITestOutputHelper log) : base(log) + { + } + + [Fact] + public void It_builds_the_project_successfully() + { + // NOTE the project dependencies in AppWithTransitiveNonSdkProjectRefs: + // TestApp --depends on--> MainLibrary --depends on--> AuxLibrary (non-SDK) + // (TestApp transitively depends on AuxLibrary) + + var testAsset = _testAssetsManager + .CopyTestAsset("AppWithTransitiveNonSdkProjectRefs", "BuildAppWithTransitiveProjectRef") + .WithSource(); + + VerifyAppBuilds(testAsset); + } + + [Fact] + public void It_builds_deps_correctly_when_projects_do_not_get_restored() + { + // NOTE the project dependencies in AppWithTransitiveProjectRefs: + // TestApp --depends on--> MainLibrary --depends on--> AuxLibrary + // (TestApp transitively depends on AuxLibrary) + var testAsset = _testAssetsManager + .CopyTestAsset("AppWithTransitiveNonSdkProjectRefs", "BuildAppWithTransitiveNonSdkProjectRefsNoRestore") + .WithSource() + .WithProjectChanges( + (projectName, project) => + { + if (StringComparer.OrdinalIgnoreCase.Equals(Path.GetFileNameWithoutExtension(projectName), "AuxLibrary") || + StringComparer.OrdinalIgnoreCase.Equals(Path.GetFileNameWithoutExtension(projectName), "MainLibrary")) + { + var ns = project.Root.Name.Namespace; + + // indicate that project restore is not supported for these projects: + var target = new XElement(ns + "Target", + new XAttribute("Name", "_IsProjectRestoreSupported"), + new XAttribute("Returns", "@(_ValidProjectsForRestore)")); + + project.Root.Add(target); + } + }); + + string outputDirectory = VerifyAppBuilds(testAsset); + + using (var depsJsonFileStream = File.OpenRead(Path.Combine(outputDirectory, "TestApp.deps.json"))) + { + var dependencyContext = new DependencyContextJsonReader().Read(depsJsonFileStream); + + var projectNames = dependencyContext.RuntimeLibraries.Select(library => library.Name).ToList(); + projectNames.Should().BeEquivalentTo(new[] { "TestApp", "AuxLibrary", "MainLibrary" }); + } + } + + private string VerifyAppBuilds(TestAsset testAsset) + { + var buildCommand = new BuildCommand(testAsset, "TestApp"); + var outputDirectory = buildCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework); + + buildCommand + .Execute() + .Should() + .Pass(); + + outputDirectory.Should().OnlyHaveFiles(new[] { + "TestApp.dll", + "TestApp.pdb", + $"TestApp{EnvironmentInfo.ExecutableExtension}", + "TestApp.deps.json", + "TestApp.runtimeconfig.json", + "MainLibrary.dll", + "MainLibrary.pdb", + "AuxLibrary.dll", + "AuxLibrary.pdb", + }); + + new DotnetCommand(Log, Path.Combine(outputDirectory.FullName, "TestApp.dll")) + .Execute() + .Should() + .Pass() + .And + .HaveStdOutContaining("This string came from MainLibrary!") + .And + .HaveStdOutContaining("This string came from AuxLibrary!"); + + return outputDirectory.FullName; + } + } +} diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveProjectRefs.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveProjectRefs.cs index c8086768b40f..479a30b06e9c 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveProjectRefs.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveProjectRefs.cs @@ -123,7 +123,9 @@ public void It_does_not_build_the_project_successfully() buildCommand .Execute("/p:DisableTransitiveProjectReferences=true") .Should() - .Fail(); + .Fail() + .And + .HaveStdOutContaining("CS0103"); } } } From 19e3a8f59914b6fc4837b688668eea4dd057cba1 Mon Sep 17 00:00:00 2001 From: William Rall Date: Fri, 4 Nov 2022 16:16:41 -0700 Subject: [PATCH 2/7] PR feedback --- .../AuxLibrary/AuxLibrary.csproj | 58 -------- .../AuxLibrary/Helper.cs | 15 -- .../MainLibrary/Helper.cs | 16 -- .../MainLibrary/MainLibrary.csproj | 61 -------- .../TestApp/Program.cs | 16 -- .../TestApp/TestApp.csproj | 10 -- .../ReferenceInfo.cs | 9 +- ...ildAnAppWithTransitiveNonSdkProjectRefs.cs | 137 ++++++++++++++---- 8 files changed, 114 insertions(+), 208 deletions(-) delete mode 100644 src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/AuxLibrary/AuxLibrary.csproj delete mode 100644 src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/AuxLibrary/Helper.cs delete mode 100644 src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/MainLibrary/Helper.cs delete mode 100644 src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/MainLibrary/MainLibrary.csproj delete mode 100644 src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/TestApp/Program.cs delete mode 100644 src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/TestApp/TestApp.csproj diff --git a/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/AuxLibrary/AuxLibrary.csproj b/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/AuxLibrary/AuxLibrary.csproj deleted file mode 100644 index b7fdb1b2e28c..000000000000 --- a/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/AuxLibrary/AuxLibrary.csproj +++ /dev/null @@ -1,58 +0,0 @@ - - - - - Debug - AnyCPU - 9a8d9cf9-379b-45c1-a95a-482ecb76a56c - Library - Properties - $(MSBuildProjectName) - $(MSBuildProjectName) - v4.6.2 - 512 - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/AuxLibrary/Helper.cs b/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/AuxLibrary/Helper.cs deleted file mode 100644 index 65b9edb1719e..000000000000 --- a/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/AuxLibrary/Helper.cs +++ /dev/null @@ -1,15 +0,0 @@ -// 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; - -namespace AuxLibrary -{ - public static class Helper - { - public static void WriteMessage() - { - Console.WriteLine("This string came from AuxLibrary!"); - } - } -} diff --git a/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/MainLibrary/Helper.cs b/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/MainLibrary/Helper.cs deleted file mode 100644 index f7f089c2d817..000000000000 --- a/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/MainLibrary/Helper.cs +++ /dev/null @@ -1,16 +0,0 @@ -// 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; - -namespace MainLibrary -{ - public static class Helper - { - public static void WriteMessage() - { - Console.WriteLine("This string came from MainLibrary!"); - AuxLibrary.Helper.WriteMessage(); - } - } -} diff --git a/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/MainLibrary/MainLibrary.csproj b/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/MainLibrary/MainLibrary.csproj deleted file mode 100644 index 69b9e61f4bea..000000000000 --- a/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/MainLibrary/MainLibrary.csproj +++ /dev/null @@ -1,61 +0,0 @@ - - - - - Debug - AnyCPU - a60a2336-1e2d-4c7a-85cb-a9e890e2558b - Library - Properties - $(MSBuildProjectName) - $(MSBuildProjectName) - v4.6.2 - 512 - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/TestApp/Program.cs b/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/TestApp/Program.cs deleted file mode 100644 index b803e73560bd..000000000000 --- a/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/TestApp/Program.cs +++ /dev/null @@ -1,16 +0,0 @@ -// 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; - -namespace TestApp -{ - public class Program - { - public static void Main(string[] args) - { - Console.WriteLine("TestApp --depends on--> MainLibrary --depends on--> AuxLibrary"); - MainLibrary.Helper.WriteMessage(); - } - } -} diff --git a/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/TestApp/TestApp.csproj b/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/TestApp/TestApp.csproj deleted file mode 100644 index bb9d5646f68f..000000000000 --- a/src/Assets/TestProjects/AppWithTransitiveNonSdkProjectRefs/TestApp/TestApp.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - Exe - $(CurrentTargetFramework) - false - - - - - \ No newline at end of file diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/ReferenceInfo.cs b/src/Tasks/Microsoft.NET.Build.Tasks/ReferenceInfo.cs index 7736a43eea22..163c54d9d6ad 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/ReferenceInfo.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/ReferenceInfo.cs @@ -69,11 +69,14 @@ bool lockFileContainsProject(ITaskItem referencePath) return false; } - string outputName = Path.GetFileName(referencePath.ItemSpec); - string projectName = Path.GetFileNameWithoutExtension(outputName); + string projectName = referencePath.GetMetadata(MetadataKeys.MSBuildSourceProjectFile); if (string.IsNullOrEmpty(projectName)) { - return true; + projectName = Path.GetFileNameWithoutExtension(referencePath.ItemSpec); + if (string.IsNullOrEmpty(projectName)) + { + return true; + } } return lockFileLookup.GetProject(projectName) != null; diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveNonSdkProjectRefs.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveNonSdkProjectRefs.cs index fed0e50dd911..b4ba4cf54cae 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveNonSdkProjectRefs.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveNonSdkProjectRefs.cs @@ -1,21 +1,20 @@ // 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.Collections.Generic; -using System.Diagnostics; +using System; using System.IO; -using System.Runtime.InteropServices; -using Microsoft.DotNet.Cli.Utils; +using System.Linq; +using System.Xml.Linq; + +using FluentAssertions; +using Microsoft.Extensions.DependencyModel; using Microsoft.NET.TestFramework; using Microsoft.NET.TestFramework.Assertions; using Microsoft.NET.TestFramework.Commands; +using Microsoft.NET.TestFramework.ProjectConstruction; + using Xunit; -using FluentAssertions; -using System.Xml.Linq; -using System.Linq; -using System; using Xunit.Abstractions; -using Microsoft.Extensions.DependencyModel; namespace Microsoft.NET.Build.Tests { @@ -25,37 +24,45 @@ public GivenThatWeWantToBuildAnAppWithTransitiveNonSdkProjectRefs(ITestOutputHel { } - [Fact] + [WindowsOnlyFact] public void It_builds_the_project_successfully() { - // NOTE the project dependencies in AppWithTransitiveNonSdkProjectRefs: + // NOTE the projects created by CreateTestProject: // TestApp --depends on--> MainLibrary --depends on--> AuxLibrary (non-SDK) // (TestApp transitively depends on AuxLibrary) - var testAsset = _testAssetsManager - .CopyTestAsset("AppWithTransitiveNonSdkProjectRefs", "BuildAppWithTransitiveProjectRef") - .WithSource(); + .CreateTestProject(CreateTestProject()); - VerifyAppBuilds(testAsset); + VerifyAppBuilds(testAsset, string.Empty); } - [Fact] - public void It_builds_deps_correctly_when_projects_do_not_get_restored() + [WindowsOnlyTheory] + [InlineData("")] + [InlineData("TestApp.")] + public void It_builds_deps_correctly_when_projects_do_not_get_restored(string prefix) { - // NOTE the project dependencies in AppWithTransitiveProjectRefs: + // NOTE the projects created by CreateTestProject: // TestApp --depends on--> MainLibrary --depends on--> AuxLibrary // (TestApp transitively depends on AuxLibrary) var testAsset = _testAssetsManager - .CopyTestAsset("AppWithTransitiveNonSdkProjectRefs", "BuildAppWithTransitiveNonSdkProjectRefsNoRestore") - .WithSource() + .CreateTestProject(CreateTestProject()) .WithProjectChanges( (projectName, project) => { - if (StringComparer.OrdinalIgnoreCase.Equals(Path.GetFileNameWithoutExtension(projectName), "AuxLibrary") || - StringComparer.OrdinalIgnoreCase.Equals(Path.GetFileNameWithoutExtension(projectName), "MainLibrary")) + string projectFileName = Path.GetFileNameWithoutExtension(projectName); + if (StringComparer.OrdinalIgnoreCase.Equals(projectFileName, "AuxLibrary") || + StringComparer.OrdinalIgnoreCase.Equals(projectFileName, "MainLibrary")) { var ns = project.Root.Name.Namespace; + if (!string.IsNullOrEmpty(prefix)) + { + XElement propertyGroup = project.Root.Element(XName.Get("PropertyGroup", ns.NamespaceName)); + XElement assemblyName = propertyGroup.Element(XName.Get("AssemblyName", ns.NamespaceName)); + assemblyName.RemoveAll(); + assemblyName.Add("TestApp." + projectFileName); + } + // indicate that project restore is not supported for these projects: var target = new XElement(ns + "Target", new XAttribute("Name", "_IsProjectRestoreSupported"), @@ -65,18 +72,90 @@ public void It_builds_deps_correctly_when_projects_do_not_get_restored() } }); - string outputDirectory = VerifyAppBuilds(testAsset); + string outputDirectory = VerifyAppBuilds(testAsset, prefix); using (var depsJsonFileStream = File.OpenRead(Path.Combine(outputDirectory, "TestApp.deps.json"))) { var dependencyContext = new DependencyContextJsonReader().Read(depsJsonFileStream); var projectNames = dependencyContext.RuntimeLibraries.Select(library => library.Name).ToList(); - projectNames.Should().BeEquivalentTo(new[] { "TestApp", "AuxLibrary", "MainLibrary" }); + projectNames.Should().BeEquivalentTo(new[] { "TestApp", prefix + "AuxLibrary", prefix + "MainLibrary" }); } } - private string VerifyAppBuilds(TestAsset testAsset) + private TestProject CreateTestProject() + { + string targetFrameworkVersion = "v4.8"; + + var auxLibraryProject = new TestProject("AuxLibrary") + { + IsSdkProject = false, + TargetFrameworkVersion = targetFrameworkVersion + }; + auxLibraryProject.SourceFiles["Helper.cs"] = """ + using System; + + namespace AuxLibrary + { + public static class Helper + { + public static void WriteMessage() + { + Console.WriteLine("This string came from AuxLibrary!"); + } + } + } + """; + + var mainLibraryProject = new TestProject("MainLibrary") + { + IsSdkProject = false, + TargetFrameworkVersion = targetFrameworkVersion + }; + mainLibraryProject.ReferencedProjects.Add(auxLibraryProject); + mainLibraryProject.SourceFiles["Helper.cs"] = """ + using System; + + namespace MainLibrary + { + public static class Helper + { + public static void WriteMessage() + { + Console.WriteLine("This string came from MainLibrary!"); + AuxLibrary.Helper.WriteMessage(); + } + } + } + """; + + var testAppProject = new TestProject("TestApp") + { + IsExe = true, + TargetFrameworks = ToolsetInfo.CurrentTargetFramework + }; + testAppProject.AdditionalProperties["ProduceReferenceAssembly"] = "false"; + testAppProject.ReferencedProjects.Add(mainLibraryProject); + testAppProject.SourceFiles["Program.cs"] = """ + using System; + + namespace TestApp + { + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine("TestApp --depends on--> MainLibrary --depends on--> AuxLibrary"); + MainLibrary.Helper.WriteMessage(); + } + } + } + """; + + return testAppProject; + } + + private string VerifyAppBuilds(TestAsset testAsset, string prefix) { var buildCommand = new BuildCommand(testAsset, "TestApp"); var outputDirectory = buildCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework); @@ -92,10 +171,10 @@ private string VerifyAppBuilds(TestAsset testAsset) $"TestApp{EnvironmentInfo.ExecutableExtension}", "TestApp.deps.json", "TestApp.runtimeconfig.json", - "MainLibrary.dll", - "MainLibrary.pdb", - "AuxLibrary.dll", - "AuxLibrary.pdb", + prefix + "MainLibrary.dll", + prefix + "MainLibrary.pdb", + prefix + "AuxLibrary.dll", + prefix + "AuxLibrary.pdb", }); new DotnetCommand(Log, Path.Combine(outputDirectory.FullName, "TestApp.dll")) From 71d5b2c2358238510a0be89ca6f4946c9dbe6ebd Mon Sep 17 00:00:00 2001 From: William Rall Date: Wed, 9 Nov 2022 18:29:39 -0800 Subject: [PATCH 3/7] PR comment fixes, fix to problematic update --- .../Microsoft.NET.Build.Tasks/GenerateDepsFile.cs | 2 +- src/Tasks/Microsoft.NET.Build.Tasks/ReferenceInfo.cs | 11 +++++++++-- ...WantToBuildAnAppWithTransitiveNonSdkProjectRefs.cs | 6 +++--- ...GivenThatWeWantToPublishAProjectWithAllFeatures.cs | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs index ec0584c4162f..bd2213636a55 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs @@ -155,7 +155,7 @@ private void WriteDepsFile(string depsFilePath) IEnumerable referenceAssemblyInfos = ReferenceInfo.CreateReferenceInfos(ReferenceAssemblies); - // If there is a generated asset file. The projectContext will have most project references. + // If there is a generated asset file, the projectContext will contain most of the project references. // So remove any project reference contained within projectContext from directReferences to avoid duplication IEnumerable directReferences = ReferenceInfo.CreateDirectReferenceInfos( diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/ReferenceInfo.cs b/src/Tasks/Microsoft.NET.Build.Tasks/ReferenceInfo.cs index 163c54d9d6ad..968cd02e6ff6 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/ReferenceInfo.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/ReferenceInfo.cs @@ -69,12 +69,19 @@ bool lockFileContainsProject(ITaskItem referencePath) return false; } - string projectName = referencePath.GetMetadata(MetadataKeys.MSBuildSourceProjectFile); - if (string.IsNullOrEmpty(projectName)) + string projectName; + string projectFilePath = referencePath.GetMetadata(MetadataKeys.MSBuildSourceProjectFile); + if (!string.IsNullOrEmpty(projectFilePath)) { + projectName = Path.GetFileNameWithoutExtension(projectFilePath); + } + else + { + // fall back to using the path to the output DLL projectName = Path.GetFileNameWithoutExtension(referencePath.ItemSpec); if (string.IsNullOrEmpty(projectName)) { + // unexpected - let's assume this project was already included in the assets file. return true; } } diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveNonSdkProjectRefs.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveNonSdkProjectRefs.cs index b4ba4cf54cae..6fb0671b02cf 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveNonSdkProjectRefs.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveNonSdkProjectRefs.cs @@ -57,10 +57,10 @@ public void It_builds_deps_correctly_when_projects_do_not_get_restored(string pr if (!string.IsNullOrEmpty(prefix)) { - XElement propertyGroup = project.Root.Element(XName.Get("PropertyGroup", ns.NamespaceName)); - XElement assemblyName = propertyGroup.Element(XName.Get("AssemblyName", ns.NamespaceName)); + XElement propertyGroup = project.Root.Element(ns + "PropertyGroup"); + XElement assemblyName = propertyGroup.Element(ns + "AssemblyName"); assemblyName.RemoveAll(); - assemblyName.Add("TestApp." + projectFileName); + assemblyName.Add(prefix + projectFileName); } // indicate that project restore is not supported for these projects: diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAProjectWithAllFeatures.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAProjectWithAllFeatures.cs index 302e5d4582ff..46b6a3358ece 100644 --- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAProjectWithAllFeatures.cs +++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAProjectWithAllFeatures.cs @@ -118,7 +118,7 @@ public void It_publishes_the_project_correctly(string targetFramework, string [] public void It_fails_when_nobuild_is_set_and_build_was_not_performed_previously() { var publishCommand = GetPublishCommand(ToolsetInfo.CurrentTargetFramework).Execute("/p:NoBuild=true"); - publishCommand.Should().Fail().And.HaveStdOutContaining("MSB3030"); // "Could not copy ___ because it was not found." + publishCommand.Should().Fail().And.HaveStdOutContaining("MSB4018"); // GenerateDepsFile fails because TestLibrary.dll cannot be found } [Theory] From 98714fa31616738e83dc66320e62d9ecb3eaab6a Mon Sep 17 00:00:00 2001 From: William Rall Date: Wed, 9 Nov 2022 19:33:41 -0800 Subject: [PATCH 4/7] fix test again --- .../GivenThatWeWantToPublishAProjectWithAllFeatures.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAProjectWithAllFeatures.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAProjectWithAllFeatures.cs index 46b6a3358ece..302e5d4582ff 100644 --- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAProjectWithAllFeatures.cs +++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAProjectWithAllFeatures.cs @@ -118,7 +118,7 @@ public void It_publishes_the_project_correctly(string targetFramework, string [] public void It_fails_when_nobuild_is_set_and_build_was_not_performed_previously() { var publishCommand = GetPublishCommand(ToolsetInfo.CurrentTargetFramework).Execute("/p:NoBuild=true"); - publishCommand.Should().Fail().And.HaveStdOutContaining("MSB4018"); // GenerateDepsFile fails because TestLibrary.dll cannot be found + publishCommand.Should().Fail().And.HaveStdOutContaining("MSB3030"); // "Could not copy ___ because it was not found." } [Theory] From e46be67fcac68935a0952e998dc6694206e1dfb2 Mon Sep 17 00:00:00 2001 From: William Rall Date: Fri, 11 Nov 2022 17:50:02 -0800 Subject: [PATCH 5/7] Add a property that controls whether to use the new behavior or not --- .../GivenADependencyContextBuilder.cs | 3 ++- .../Microsoft.NET.Build.Tasks/GenerateDepsFile.cs | 5 ++++- src/Tasks/Microsoft.NET.Build.Tasks/ReferenceInfo.cs | 8 +++++++- .../targets/Microsoft.NET.DesignerSupport.targets | 1 + .../targets/Microsoft.NET.Publish.targets | 3 ++- .../targets/Microsoft.NET.Sdk.DefaultItems.props | 5 +++++ .../targets/Microsoft.NET.Sdk.targets | 3 ++- ...antToBuildAnAppWithTransitiveNonSdkProjectRefs.cs | 12 +++++++++++- 8 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenADependencyContextBuilder.cs b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenADependencyContextBuilder.cs index b3a13c52492f..a0b6f088b5df 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenADependencyContextBuilder.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenADependencyContextBuilder.cs @@ -54,7 +54,8 @@ public void ItBuildsDependencyContextsFromProjectLockFiles( referencePaths ?? new ITaskItem[] { }, referenceSatellitePaths ?? new ITaskItem[] { }, lockFileLookup: lockFileLookup, - i => true); + i => true, + true); ProjectContext projectContext = lockFile.CreateProjectContext( FrameworkConstants.CommonFrameworks.NetCoreApp10.GetShortFolderName(), diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs index bd2213636a55..dc71c6e3ac7b 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs @@ -94,6 +94,8 @@ public class GenerateDepsFile : TaskWithAssemblyResolveHooks public bool IncludeRuntimeFileVersions { get; set; } + public bool IncludeProjectsNotInAssetsFile { get; set; } + [Required] public string RuntimeGraphPath { get; set; } @@ -162,7 +164,8 @@ private void WriteDepsFile(string depsFilePath) ReferencePaths, ReferenceSatellitePaths, lockFileLookup, - isUserRuntimeAssembly); + isUserRuntimeAssembly, + IncludeProjectsNotInAssetsFile); IEnumerable dependencyReferences = ReferenceInfo.CreateDependencyReferenceInfos(ReferenceDependencyPaths, ReferenceSatellitePaths, isUserRuntimeAssembly); diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/ReferenceInfo.cs b/src/Tasks/Microsoft.NET.Build.Tasks/ReferenceInfo.cs index 968cd02e6ff6..11ad32000307 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/ReferenceInfo.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/ReferenceInfo.cs @@ -55,7 +55,8 @@ public static IEnumerable CreateDirectReferenceInfos( IEnumerable referencePaths, IEnumerable referenceSatellitePaths, LockFileLookup lockFileLookup, - Func isRuntimeAssembly) + Func isRuntimeAssembly, + bool includeProjectsNotInAssetsFile) { bool lockFileContainsProject(ITaskItem referencePath) { @@ -69,6 +70,11 @@ bool lockFileContainsProject(ITaskItem referencePath) return false; } + if (!includeProjectsNotInAssetsFile) + { + return true; + } + string projectName; string projectFilePath = referencePath.GetMetadata(MetadataKeys.MSBuildSourceProjectFile); if (!string.IsNullOrEmpty(projectFilePath)) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.DesignerSupport.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.DesignerSupport.targets index 31e6ec5f694d..000e7153f1b4 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.DesignerSupport.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.DesignerSupport.targets @@ -68,6 +68,7 @@ Copyright (c) .NET Foundation. All rights reserved. ResolvedRuntimeTargetsFiles="@(RuntimeTargetsCopyLocalItems)" TargetFramework="$(TargetFramework)" RuntimeGraphPath="$(BundledRuntimeIdentifierGraphFile)" + IncludeProjectsNotInAssetsFile="$(IncludeProjectsNotInAssetsFileInDepsFile)" /> diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets index a943e6615bf4..09f458a7909b 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets @@ -986,7 +986,8 @@ Copyright (c) .NET Foundation. All rights reserved. IsSelfContained="$(SelfContained)" IsSingleFile="$(_IsSingleFilePublish)" IncludeRuntimeFileVersions="$(IncludeFileVersionsInDependencyFile)" - RuntimeGraphPath="$(BundledRuntimeIdentifierGraphFile)"/> + RuntimeGraphPath="$(BundledRuntimeIdentifierGraphFile)" + IncludeProjectsNotInAssetsFile="$(IncludeProjectsNotInAssetsFileInDepsFile)"/> diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.DefaultItems.props b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.DefaultItems.props index 1c660c6e23cc..2ace013bec47 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.DefaultItems.props +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.DefaultItems.props @@ -32,6 +32,11 @@ Copyright (c) .NET Foundation. All rights reserved. <__WindowsAppSdkDefaultImageIncludes>**/*.png;**/*.bmp;**/*.jpg;**/*.dds;**/*.tif;**/*.tga;**/*.gif + + + false + + diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets index 4311ec0ecea2..721576314c2e 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets @@ -213,7 +213,8 @@ Copyright (c) .NET Foundation. All rights reserved. ResolvedRuntimeTargetsFiles="@(RuntimeTargetsCopyLocalItems)" IsSelfContained="$(SelfContained)" IncludeRuntimeFileVersions="$(IncludeFileVersionsInDependencyFile)" - RuntimeGraphPath="$(BundledRuntimeIdentifierGraphFile)"/> + RuntimeGraphPath="$(BundledRuntimeIdentifierGraphFile)" + IncludeProjectsNotInAssetsFile="$(IncludeProjectsNotInAssetsFileInDepsFile)"/> - false - - diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets index 721576314c2e..1c3ba05e59c4 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets @@ -125,6 +125,11 @@ Copyright (c) .NET Foundation. All rights reserved. false + + + false + + _CheckForBuildWithNoBuild; From 14fdc0013293349371c2acb87be93ad26cd2f3ef Mon Sep 17 00:00:00 2001 From: William Rall Date: Wed, 16 Nov 2022 15:11:59 -0800 Subject: [PATCH 7/7] Enable new behavior by default as per PR feedback --- .../targets/Microsoft.NET.Sdk.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets index 1c3ba05e59c4..2fc132cd2e42 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets @@ -126,8 +126,8 @@ Copyright (c) .NET Foundation. All rights reserved. - - false + + true