-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
c9c71cf
commit 2902de7
Showing
13 changed files
with
231 additions
and
58 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
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
33 changes: 0 additions & 33 deletions
33
src/Scaffolding/VS.Web.CG.Utils/ProjectContextExtensions.cs
This file was deleted.
Oops, something went wrong.
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
67 changes: 67 additions & 0 deletions
67
src/Shared/Microsoft.DotNet.Scaffolding.Shared/ProjectModel/ProjectContextExtensions.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,67 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
using Microsoft.VisualStudio.Web.CodeGeneration.Msbuild; | ||
using Microsoft.VisualStudio.Web.CodeGeneration.Utils; | ||
|
||
namespace Microsoft.DotNet.Scaffolding.Shared.ProjectModel | ||
{ | ||
public static class ProjectContextExtensions | ||
{ | ||
public static DependencyDescription GetPackage(this IProjectContext context, string name) | ||
{ | ||
Requires.NotNullOrEmpty(name, nameof(name)); | ||
Requires.NotNull(context, nameof(context)); | ||
|
||
return context.PackageDependencies.FirstOrDefault(package => package.Name.Equals(name, StringComparison.OrdinalIgnoreCase)); | ||
} | ||
|
||
public static IEnumerable<DependencyDescription> GetReferencingPackages(this IProjectContext context, string name) | ||
{ | ||
Requires.NotNullOrEmpty(name, nameof(name)); | ||
Requires.NotNull(context, nameof(context)); | ||
|
||
return context | ||
.PackageDependencies | ||
.Where(package => package | ||
.Dependencies | ||
.Any(dep => dep.Name.Equals(name, StringComparison.OrdinalIgnoreCase))); | ||
} | ||
public static IProjectContext AddPackageDependencies(this IProjectContext projectInformation, string projectAssetsFile) | ||
{ | ||
//get project assets file | ||
var packageDependencies = ProjectContextWriter.GetPackageDependencies(projectAssetsFile, projectInformation.TargetFramework, projectInformation.TargetFrameworkMoniker); | ||
var additionalCompilation = ProjectContextWriter.GetScaffoldingAssemblies(packageDependencies).ToList(); | ||
var compilationList = projectInformation.CompilationAssemblies.ToList(); | ||
compilationList.AddRange(additionalCompilation); | ||
var newProjectContext = new CommonProjectContext() | ||
{ | ||
AssemblyFullPath = projectInformation.AssemblyFullPath, | ||
AssemblyName = projectInformation.AssemblyName, | ||
CompilationAssemblies = compilationList, | ||
CompilationItems = projectInformation.CompilationItems, | ||
PackageDependencies = packageDependencies, | ||
Config = projectInformation.Config, | ||
Configuration = projectInformation.Configuration, | ||
DepsFile = projectInformation.DepsFile, | ||
EmbededItems = projectInformation.EmbededItems, | ||
IsClassLibrary = projectInformation.IsClassLibrary, | ||
Platform = projectInformation.Platform, | ||
ProjectFullPath = projectInformation.ProjectFullPath, | ||
ProjectName = projectInformation.ProjectName, | ||
ProjectReferences = projectInformation.ProjectReferences, | ||
RootNamespace = projectInformation.RootNamespace, | ||
RuntimeConfig = projectInformation.RuntimeConfig, | ||
TargetDirectory = projectInformation.TargetDirectory, | ||
TargetFramework = projectInformation.TargetFramework, | ||
TargetFrameworkMoniker = projectInformation.TargetFrameworkMoniker, | ||
GeneratedImplicitNamespaceImportFile = projectInformation.GeneratedImplicitNamespaceImportFile | ||
}; | ||
return newProjectContext; | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.