Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Commit

Permalink
DTH applies out-of-date lock file to reduce error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ChengTian committed Mar 24, 2015
1 parent b61b3f8 commit 7ea973d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/Microsoft.Framework.DesignTimeHost/ApplicationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,8 @@ private ApplicationHostContext GetApplicationHostContext(Project project, string
cache: _cache,
cacheContextAccessor: _cacheContextAccessor,
namedCacheDependencyProvider: _namedDependencyProvider,
loadContextFactory: GetRuntimeLoadContextFactory(project));
loadContextFactory: GetRuntimeLoadContextFactory(project),
skipLockFileValidation: true);
applicationHostContext.DependencyWalker.Walk(project.Name, project.Version, frameworkName);
Expand Down
9 changes: 5 additions & 4 deletions src/Microsoft.Framework.Runtime/ApplicationHostContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public class ApplicationHostContext
ICache cache,
ICacheContextAccessor cacheContextAccessor,
INamedCacheDependencyProvider namedCacheDependencyProvider,
IAssemblyLoadContextFactory loadContextFactory = null)
IAssemblyLoadContextFactory loadContextFactory = null,
bool skipLockFileValidation = false)
{
ProjectDirectory = projectDirectory;
Configuration = configuration;
Expand Down Expand Up @@ -67,7 +68,7 @@ public class ApplicationHostContext
var lockFile = lockFileFormat.Read(projectLockJsonPath);
validLockFile = lockFile.IsValidForProject(Project);

if (validLockFile)
if (validLockFile || skipLockFileValidation)
{
NuGetDependencyProvider.ApplyLockFile(lockFile);

Expand All @@ -81,9 +82,9 @@ public class ApplicationHostContext
}
}

if (!lockFileExists || !validLockFile)
if (!validLockFile && !skipLockFileValidation)
{
// If we are unable to apply the lockfile, we don't add NuGetDependencyProvider to DependencyWalker
// We don't add NuGetDependencyProvider to DependencyWalker
// It will leave all NuGet packages unresolved and give error message asking users to run "kpm restore"
DependencyWalker = new DependencyWalker(new IDependencyProvider[] {
ProjectDepencyProvider,
Expand Down

0 comments on commit 7ea973d

Please sign in to comment.