Merge pull request #2249 from dotnet/troy/2200
Use default version for unresolved MSBuild reference
This commit is contained in:
commit
cb14076b38
2 changed files with 38 additions and 2 deletions
|
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using Microsoft.DotNet.ProjectModel.Compilation;
|
||||
using Microsoft.DotNet.ProjectModel.Graph;
|
||||
using NuGet.Versioning;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Models
|
||||
{
|
||||
|
@ -23,7 +24,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Models
|
|||
public string Type { get; private set; }
|
||||
|
||||
public bool Resolved { get; private set; }
|
||||
|
||||
|
||||
public IEnumerable<DependencyItem> Dependencies { get; private set; }
|
||||
|
||||
public IEnumerable<DiagnosticMessageView> Errors { get; private set; }
|
||||
|
@ -60,7 +61,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Models
|
|||
{
|
||||
Name = library.Identity.Name,
|
||||
DisplayName = library.Identity.Name,
|
||||
Version = library.Identity.Version?.ToNormalizedString(),
|
||||
Version = (library.Identity.Version ?? new NuGetVersion("1.0.0")).ToNormalizedString(),
|
||||
Type = library.Identity.Type.Value,
|
||||
Resolved = library.Resolved,
|
||||
Path = library.Path,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
@ -413,6 +414,40 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddMSBuildReferenceBeforeRestore()
|
||||
{
|
||||
var tam = new TestAssetsManager(
|
||||
Path.Combine(RepoRoot, "TestAssets", "ProjectModelServer", "MSBuildReferencesProjects"));
|
||||
|
||||
// var appName = "EmptyNetCoreApp";
|
||||
var projectPath = tam.CreateTestInstance("ValidCase01").WithLockFiles().TestRoot;
|
||||
projectPath = Path.Combine(projectPath, "src", "MainApp");
|
||||
|
||||
var projectFilePath = Path.Combine(projectPath, Project.FileName);
|
||||
var projectJson = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(projectFilePath));
|
||||
|
||||
((JObject)projectJson["frameworks"]["net46"]["dependencies"])
|
||||
.Add("ClassLibrary4", JToken.FromObject(new { target = "project" }));
|
||||
|
||||
File.WriteAllText(projectFilePath, JsonConvert.SerializeObject(projectJson));
|
||||
|
||||
using (var server = new DthTestServer(_loggerFactory))
|
||||
using (var client = new DthTestClient(server, _loggerFactory))
|
||||
{
|
||||
client.Initialize(projectPath);
|
||||
var messages = client.DrainAllMessages();
|
||||
messages.AssertDoesNotContain(MessageTypes.Error);
|
||||
// PrintAllMessages(new[] { messages.RetrieveSingleMessage(MessageTypes.Dependencies) });
|
||||
messages.RetrieveSingleMessage(MessageTypes.Dependencies)
|
||||
.RetrieveDependency("ClassLibrary4")
|
||||
.AssertProperty<object>(
|
||||
"Version",
|
||||
v => !string.IsNullOrEmpty(v.ToString()),
|
||||
v => $"Version string shouldn't be empty. Value [{v.ToString()}]");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MSBuildReferenceTest()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue