LockFilePatcher should only patch when lock file has holes in it

If not, the export file is stale
This commit is contained in:
Mihai Codoban 2016-03-30 10:58:30 -07:00
parent 385a3d65da
commit d20e0d74f2
5 changed files with 74 additions and 1 deletions

View file

@ -0,0 +1,35 @@
{
"version": 2,
"exports": {
"ClassLibrary1/1.0.0": {
"type": "project",
"framework": ".NETFramework,Version=v4.5.2",
"compile": {
"bin/Debug/ClassLibrary1.dll": {}
},
"runtime": {
"bin/Debug/ClassLibrary1.dll": {}
}
},
"ClassLibrary2/1.0.0": {
"type": "project",
"framework": ".NETFramework,Version=v4.6",
"compile": {
"bin/Debug/ClassLibrary2.dll": {}
},
"runtime": {
"bin/Debug/ClassLibrary2.dll": {}
}
},
"ClassLibrary3/1.0.0": {
"type": "project",
"framework": ".NETFramework,Version=v4.6",
"compile": {
"bin/Debug/ClassLibrary3.dll": {}
},
"runtime": {
"bin/Debug/ClassLibrary3.dll": {}
}
}
}
}

View file

@ -0,0 +1,10 @@
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"frameworks": {
"net46": { }
}
}

View file

@ -0,0 +1,13 @@
{
"locked": false,
"version": 2,
"targets": {
".NETFramework,Version=v4.6": { }
},
"libraries": {
},
"projectFileDependencyGroups": {
"": [],
".NETFramework,Version=v4.6": []
}
}

View file

@ -26,7 +26,7 @@ namespace Microsoft.DotNet.ProjectModel.Graph
{
var exportFilePath = GetExportFilePath(_lockFile.LockFilePath);
if (File.Exists(exportFilePath))
if (File.Exists(exportFilePath) && _msbuildTargetLibraries.Any())
{
var exportFile = LockFileReader.ReadExportFile(exportFilePath);
PatchLockWithExport(exportFile);

View file

@ -52,6 +52,21 @@ namespace Microsoft.DotNet.ProjectModel.Tests
}
}
[Fact]
public void TestFragmentExistsButNoHolesInLockFile()
{
var lockFilePath = GetLockFilePath("valid_staleFragment");
var lockFile = LockFileReader.Read(lockFilePath);
var exportFile = lockFile.ExportFile;
exportFile.Should().BeNull();
lockFile.Targets.Count.Should().Be(1);
lockFile.Targets[0].Libraries.Count.Should().Be(0);
}
[Fact]
public void TestMissingExportFileThrows()
{