Merge branch 'upstream'

Former-commit-id: 67f7ba164dbd2ed41d7b7ffc6fcb043de4aaac2c
This commit is contained in:
Xamarin Public Jenkins (auto-signing) 2017-04-26 10:15:24 +00:00
commit 8bfaf3b3d9
47 changed files with 696 additions and 245 deletions

View File

@ -216,7 +216,11 @@ namespace Mono.Cecil.Cil {
// PDB Age
buffer.WriteUInt32 (1);
// PDB Path
buffer.WriteBytes (System.Text.Encoding.UTF8.GetBytes (writer.BaseStream.GetFileName ()));
var filename = writer.BaseStream.GetFileName ();
if (!string.IsNullOrEmpty (filename))
filename = Path.GetFileName (filename);
buffer.WriteBytes (System.Text.Encoding.UTF8.GetBytes (filename));
buffer.WriteByte (0);
header = new byte [buffer.length];

View File

@ -174,6 +174,36 @@ namespace Microsoft.NuGet.Build.Tasks.Tests.Json {
}
}
/// <summary>
/// Looks up a localized string similar to {
/// &quot;locked&quot;: false,
/// &quot;version&quot;: 2,
/// &quot;targets&quot;: {
/// &quot;.NETFramework,Version=v4.5&quot;: {
/// &quot;Newtonsoft.Json/8.0.3&quot;: {
/// &quot;type&quot;: &quot;package&quot;,
/// &quot;compile&quot;: {
/// &quot;lib/net45/Newtonsoft.Json.dll&quot;: {}
/// },
/// &quot;runtime&quot;: {
/// &quot;lib/net45/Newtonsoft.Json.dll&quot;: {}
/// }
/// }
/// },
/// &quot;.NETFramework,Version=v4.6&quot;: {
/// &quot;FluentAssertions/3.4.1&quot;: {
/// &quot;frameworkAssemblies&quot;: [
/// &quot;System.Xml&quot;,
/// &quot;System.Xml.Linq&quot;
/// ],
/// [rest of string was truncated]&quot;;.
/// </summary>
internal static string MultipleProjectFileDependencyGroups {
get {
return ResourceManager.GetString("MultipleProjectFileDependencyGroups", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {
/// &quot;locked&quot;: false,
@ -201,6 +231,35 @@ namespace Microsoft.NuGet.Build.Tasks.Tests.Json {
}
}
/// <summary>
/// Looks up a localized string similar to {
/// &quot;version&quot;: 2,
/// &quot;targets&quot;: {
/// &quot;.NETFramework,Version=v4.5.2&quot;: {
/// &quot;log4net/2.0.7&quot;: {
/// &quot;type&quot;: &quot;package&quot;,
/// &quot;compile&quot;: {
/// &quot;lib/net45-full/log4net.dll&quot;: {}
/// },
/// &quot;runtime&quot;: {
/// &quot;lib/net45-full/log4net.dll&quot;: {}
/// }
/// },
/// &quot;Newtonsoft.Json/9.0.1&quot;: {
/// &quot;type&quot;: &quot;package&quot;,
/// &quot;compile&quot;: {
/// &quot;lib/net45/Newtonsoft.Json.dll&quot;: {}
/// },
/// &quot;runtime&quot;: {
/// &quot;lib/net45/Newtonsoft.Json.dll&quot;: {}
/// [rest of string was truncated]&quot;;.
/// </summary>
internal static string ProjectDependency {
get {
return ResourceManager.GetString("ProjectDependency", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {
/// &quot;locked&quot;: false,

View File

@ -142,4 +142,10 @@
<data name="LockFileWithWithSpecifiedPackageFolders" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>lockfilewithwithspecifiedpackagefolders.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="MultipleProjectFileDependencyGroups" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>multipleprojectfiledependencygroups.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="ProjectDependency" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>ProjectDependency.assets.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root>

View File

@ -0,0 +1,150 @@
{
"locked": false,
"version": 2,
"targets": {
".NETFramework,Version=v4.5": {
"Newtonsoft.Json/8.0.3": {
"type": "package",
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
}
},
".NETFramework,Version=v4.6": {
"FluentAssertions/3.4.1": {
"frameworkAssemblies": [
"System.Xml",
"System.Xml.Linq"
],
"compile": {
"lib/net45/FluentAssertions.Core.dll": {},
"lib/net45/FluentAssertions.dll": {}
},
"runtime": {
"lib/net45/FluentAssertions.Core.dll": {},
"lib/net45/FluentAssertions.dll": {}
}
}
}
},
"libraries": {
"Newtonsoft.Json/8.0.3": {
"sha512": "KGsYQdS2zLH+H8x2cZaSI7e+YZ4SFIbyy1YJQYl6GYBWjf5o4H1A68nxyq+WTyVSOJQ4GqS/DiPE+UseUizgMg==",
"type": "package",
"path": "newtonsoft.json/8.0.3",
"files": [
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81+dnxcore50/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81+dnxcore50/Newtonsoft.Json.xml",
"newtonsoft.json.8.0.3.nupkg.sha512",
"newtonsoft.json.nuspec",
"tools/install.ps1"
]
},
"FluentAssertions/3.4.1": {
"sha512": "GTyLzP7d57D3HLVOSFrTSVwod3rZNQRMC2DR13u1hNNyhsskLrbI4SW5XXqyEv8WP7v8IqWx9hdlDiwLY0G8YA==",
"type": "Package",
"files": [
"_rels/.rels",
"FluentAssertions.nuspec",
"lib/net40/FluentAssertions.Core.dll",
"lib/net40/FluentAssertions.Core.pdb",
"lib/net40/FluentAssertions.Core.xml",
"lib/net40/FluentAssertions.dll",
"lib/net40/FluentAssertions.pdb",
"lib/net40/FluentAssertions.xml",
"lib/net45/FluentAssertions.Core.dll",
"lib/net45/FluentAssertions.Core.pdb",
"lib/net45/FluentAssertions.Core.xml",
"lib/net45/FluentAssertions.dll",
"lib/net45/FluentAssertions.pdb",
"lib/net45/FluentAssertions.xml",
"lib/portable-monotouch+monoandroid+xamarin.ios/FluentAssertions.Core.dll",
"lib/portable-monotouch+monoandroid+xamarin.ios/FluentAssertions.Core.pdb",
"lib/portable-monotouch+monoandroid+xamarin.ios/FluentAssertions.Core.xml",
"lib/portable-net40+sl5+win8+wp8+wpa81/FluentAssertions.Core.dll",
"lib/portable-net40+sl5+win8+wp8+wpa81/FluentAssertions.Core.pdb",
"lib/portable-net40+sl5+win8+wp8+wpa81/FluentAssertions.Core.xml",
"lib/portable-net40+sl5+win8+wp8+wpa81/FluentAssertions.dll",
"lib/portable-net40+sl5+win8+wp8+wpa81/FluentAssertions.pdb",
"lib/portable-net40+sl5+win8+wp8+wpa81/FluentAssertions.XML",
"lib/portable-win81+wpa81/FluentAssertions.Core.dll",
"lib/portable-win81+wpa81/FluentAssertions.Core.pdb",
"lib/portable-win81+wpa81/FluentAssertions.Core.xml",
"lib/portable-win81+wpa81/FluentAssertions.dll",
"lib/portable-win81+wpa81/FluentAssertions.pdb",
"lib/portable-win81+wpa81/FluentAssertions.xml",
"lib/sl5/FluentAssertions.Core.dll",
"lib/sl5/FluentAssertions.Core.pdb",
"lib/sl5/FluentAssertions.Core.xml",
"lib/sl5/FluentAssertions.dll",
"lib/sl5/FluentAssertions.pdb",
"lib/sl5/FluentAssertions.xml",
"lib/sl5/Microsoft.CSharp.dll",
"lib/sl5/Microsoft.CSharp.xml",
"lib/sl5/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll",
"lib/sl5/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.xml",
"lib/sl5/System.Xml.Linq.dll",
"lib/sl5/System.Xml.Linq.xml",
"lib/sl5/de/Microsoft.CSharp.resources.dll",
"lib/sl5/de/System.Xml.Linq.resources.dll",
"lib/sl5/es/Microsoft.CSharp.resources.dll",
"lib/sl5/es/System.Xml.Linq.resources.dll",
"lib/sl5/fr/Microsoft.CSharp.resources.dll",
"lib/sl5/fr/System.Xml.Linq.resources.dll",
"lib/sl5/it/Microsoft.CSharp.resources.dll",
"lib/sl5/it/System.Xml.Linq.resources.dll",
"lib/sl5/ja/Microsoft.CSharp.resources.dll",
"lib/sl5/ja/System.Xml.Linq.resources.dll",
"lib/sl5/ko/Microsoft.CSharp.resources.dll",
"lib/sl5/ko/System.Xml.Linq.resources.dll",
"lib/sl5/ru/Microsoft.CSharp.resources.dll",
"lib/sl5/ru/System.Xml.Linq.resources.dll",
"lib/sl5/zh-Hans/Microsoft.CSharp.resources.dll",
"lib/sl5/zh-Hans/System.Xml.Linq.resources.dll",
"lib/sl5/zh-Hant/Microsoft.CSharp.resources.dll",
"lib/sl5/zh-Hant/System.Xml.Linq.resources.dll",
"lib/win8/FluentAssertions.Core.dll",
"lib/win8/FluentAssertions.Core.pdb",
"lib/win8/FluentAssertions.Core.xml",
"lib/win8/FluentAssertions.dll",
"lib/win8/FluentAssertions.pdb",
"lib/win8/FluentAssertions.XML",
"lib/wp8/FluentAssertions.Core.dll",
"lib/wp8/FluentAssertions.Core.pdb",
"lib/wp8/FluentAssertions.Core.xml",
"lib/wp8/FluentAssertions.dll",
"lib/wp8/FluentAssertions.pdb",
"lib/wp8/FluentAssertions.xml",
"package/services/metadata/core-properties/c21a09dd42de4a6295af89109b879195.psmdcp",
"[Content_Types].xml"
]
}
},
"projectFileDependencyGroups": {
"": [],
".NETFramework,Version=v4.5": [
"Newtonsoft.Json >= 8.0.1"
],
".NETFramework,Version=v4.6": [
"FluentAssertions >= 3.4.1"
]
},
"tools": {},
"projectFileToolGroups": {},
"packageFolders": {
"C:\\PackageFolder\\": {}
}
}

View File

@ -0,0 +1,213 @@
{
"version": 2,
"targets": {
".NETFramework,Version=v4.5.2": {
"log4net/2.0.7": {
"type": "package",
"compile": {
"lib/net45-full/log4net.dll": {}
},
"runtime": {
"lib/net45-full/log4net.dll": {}
}
},
"Newtonsoft.Json/9.0.1": {
"type": "package",
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"ClassLibrary1/1.0.0": {
"type": "project"
}
},
".NETFramework,Version=v4.5.2/win": {
"log4net/2.0.7": {
"type": "package",
"compile": {
"lib/net45-full/log4net.dll": {}
},
"runtime": {
"lib/net45-full/log4net.dll": {}
}
},
"Newtonsoft.Json/9.0.1": {
"type": "package",
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"ClassLibrary1/1.0.0": {
"type": "project"
}
},
".NETFramework,Version=v4.5.2/win-x64": {
"log4net/2.0.7": {
"type": "package",
"compile": {
"lib/net45-full/log4net.dll": {}
},
"runtime": {
"lib/net45-full/log4net.dll": {}
}
},
"Newtonsoft.Json/9.0.1": {
"type": "package",
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"ClassLibrary1/1.0.0": {
"type": "project"
}
},
".NETFramework,Version=v4.5.2/win-x86": {
"log4net/2.0.7": {
"type": "package",
"compile": {
"lib/net45-full/log4net.dll": {}
},
"runtime": {
"lib/net45-full/log4net.dll": {}
}
},
"Newtonsoft.Json/9.0.1": {
"type": "package",
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"ClassLibrary1/1.0.0": {
"type": "project"
}
}
},
"libraries": {
"log4net/2.0.7": {
"sha512": "9zY5lPFy4ppjeaTKwHjXbHe6lhle64Bnwui3YDEnnlo4NzHcUE9/h4BqCn3PCCvYbpwO4+ceWdqk9J/lxrQ9dQ==",
"type": "package",
"path": "log4net/2.0.7",
"files": [
"lib/net20-full/log4net.dll",
"lib/net20-full/log4net.xml",
"lib/net35-client/log4net.dll",
"lib/net35-client/log4net.xml",
"lib/net35-full/log4net.dll",
"lib/net35-full/log4net.xml",
"lib/net40-client/log4net.dll",
"lib/net40-client/log4net.xml",
"lib/net40-full/log4net.dll",
"lib/net40-full/log4net.xml",
"lib/net45-full/log4net.dll",
"lib/net45-full/log4net.xml",
"lib/netstandard1.3/log4net.dll",
"log4net.2.0.7.nupkg.sha512",
"log4net.nuspec"
]
},
"Newtonsoft.Json/9.0.1": {
"sha512": "U82mHQSKaIk+lpSVCbWYKNavmNH1i5xrExDEquU1i6I5pV6UMOqRnJRSlKO3cMPfcpp0RgDY+8jUXHdQ4IfXvw==",
"type": "package",
"path": "newtonsoft.json/9.0.1",
"files": [
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netstandard1.0/Newtonsoft.Json.dll",
"lib/netstandard1.0/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml",
"newtonsoft.json.9.0.1.nupkg.sha512",
"newtonsoft.json.nuspec",
"tools/install.ps1"
]
},
"ClassLibrary1/1.0.0": {
"type": "project",
"path": "../ClassLibrary1/ClassLibrary1.csproj",
"msbuildProject": "../ClassLibrary1/ClassLibrary1.csproj"
}
},
"projectFileDependencyGroups": {
".NETFramework,Version=v4.5.2": [
"ClassLibrary1 >= 1.0.0",
"Newtonsoft.Json >= 9.0.1",
"log4net >= 2.0.7"
]
},
"packageFolders": {
"C:\\Users\\tomescht\\.nuget\\packages\\": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\tomescht\\Documents\\Visual Studio 2017\\Projects\\WpfApp1\\WpfApp1\\WpfApp1.csproj",
"projectName": "WpfApp1",
"projectPath": "C:\\Users\\tomescht\\Documents\\Visual Studio 2017\\Projects\\WpfApp1\\WpfApp1\\WpfApp1.csproj",
"outputPath": "C:\\Users\\tomescht\\Documents\\Visual Studio 2017\\Projects\\WpfApp1\\WpfApp1\\obj\\",
"projectStyle": "PackageReference",
"originalTargetFrameworks": [
"net452"
],
"frameworks": {
"net452": {
"projectReferences": {
"C:\\Users\\tomescht\\Documents\\Visual Studio 2017\\Projects\\WpfApp1\\ClassLibrary1\\ClassLibrary1.csproj": {
"projectPath": "C:\\Users\\tomescht\\Documents\\Visual Studio 2017\\Projects\\WpfApp1\\ClassLibrary1\\ClassLibrary1.csproj"
}
}
}
}
},
"dependencies": {
"Newtonsoft.Json": {
"target": "Package",
"version": "9.0.1"
},
"log4net": {
"target": "Package",
"version": "[2.0.7, )"
}
},
"frameworks": {
"net452": {
"dependencies": {
"Newtonsoft.Json": {
"target": "Package",
"version": "9.0.1"
}
}
}
},
"runtimes": {
"win": {
"#import": []
},
"win-x64": {
"#import": []
},
"win-x86": {
"#import": []
}
}
}
}

View File

@ -78,14 +78,15 @@
<None Include="Json\analyzers.json" />
<None Include="Json\FluentAssertions.lock.json" />
<None Include="Json\FluentAssertionsAndWin10.lock.json" />
<None Include="Json\MultipleProjectFileDependencyGroups.json" />
<None Include="Json\nativeWinMD.json" />
<None Include="Json\LockFileWithWithSpecifiedPackageFolders.json" />
<None Include="Json\Win10.Edm.json" />
<None Include="Json\Win10.json" />
<None Include="Json\Win10.xunit.json" />
<None Include="project.json" />
<None Include="Json\ProjectDependency.assets.json" />
<None Include="ProjectReferences\LockFileMissingMSBuildProjectThatProvidesAssets.json" />
<None Include="ProjectReferences\LockFileWithXProjReference.json" />
<None Include="ProjectReferences\LockFileWithCSProjReference.json" />
</ItemGroup>
<ItemGroup>

View File

@ -26,7 +26,6 @@ namespace Microsoft.NuGet.Build.Tasks.Tests
TryGetRuntimeVersion tryGetRuntimeVersion = null,
bool includeFrameworkReferences = true,
string projectJsonFileContents = null,
IEnumerable<ITaskItem> projectReferencesCreatingPackages = null,
bool createTemporaryFolderForPackages = true)
{
var rootDirectory = new TempRoot();
@ -79,7 +78,6 @@ namespace Microsoft.NuGet.Build.Tasks.Tests
task.IncludeFrameworkReferences = includeFrameworkReferences;
task.NuGetPackagesDirectory = packagesDirectory?.Path;
task.RuntimeIdentifier = runtimeIdentifier;
task.ProjectReferencesCreatingPackages = (projectReferencesCreatingPackages ?? Enumerable.Empty<ITaskItem>()).ToArray();
task.ProjectLockFile = projectLockJsonFile.Path;
task.ProjectLanguage = projectLanguage;
task.TargetMonikers = new ITaskItem[] { new TaskItem(targetMoniker) };

View File

@ -1,41 +0,0 @@
{
"locked": false,
"version": 2,
"targets": {
".NETFramework,Version=v4.5.2": {
"XProjClassLib/1.0.0": {
"type": "project",
"framework": ".NETFramework,Version=v4.5.2",
"compile": {
"net452/XProjClassLib.dll": { }
},
"runtime": {
"net452/XProjClassLib.dll": { }
}
}
},
".NETFramework,Version=v4.5.2/win": {
"XProjClassLib/1.0.0": {
"type": "project",
"framework": ".NETFramework,Version=v4.5.2",
"compile": {
"net452/XProjClassLib.dll": { }
},
"runtime": {
"net452/XProjClassLib.dll": { }
}
}
}
},
"libraries": {
"XProjClassLib/1.0.0": {
"type": "project",
"path": "../XProjClassLib/project.json",
"msbuildProject": "../XProjClassLib/XProjClassLib.xproj"
}
},
"projectFileDependencyGroups": {
"": [ ],
".NETFramework,Version=v4.5.2": [ ]
}
}

View File

@ -10,45 +10,6 @@ namespace Microsoft.NuGet.Build.Tasks.Tests.ProjectReferences
{
public class ProjectReferenceTests
{
[Fact]
public void ProjectReferenceToXProjWithAssetsButNotWithAPathFails()
{
var exception = Assert.Throws<ExceptionFromResource>(
() => NuGetTestHelpers.ResolvePackagesWithJsonFileContents(Resources.LockFileWithXProjReference, ".NETFramework,Version=v4.5.2", "win"));
Assert.Equal(nameof(Strings.MissingProjectReference), exception.ResourceName);
AssertHelpers.PathEndsWith(@"XProjClassLib\XProjClassLib.xproj", exception.MessageArgs[0]);
}
[Fact]
public void ProjectReferenceToProjectWithNoMSBuildProjectFailsGracefully()
{
var exception = Assert.Throws<ExceptionFromResource>(
() => NuGetTestHelpers.ResolvePackagesWithJsonFileContents(Resources.LockFileMissingMSBuildProjectThatProvidesAssets, ".NETFramework,Version=v4.5.2", "win"));
Assert.Equal(nameof(Strings.MissingMSBuildPathInProjectPackage), exception.ResourceName);
Assert.Equal(@"XProjClassLib", exception.MessageArgs[0]);
}
[Fact]
public void ProjectReferenceToXProjWithAssetsAndPathSucceeds()
{
var referenceToXProj = new TaskItem(@"..\XProjClassLib\XProjClassLib.xproj");
referenceToXProj.SetMetadata("OutputBasePath", "XProjOutputDirectory");
var result = NuGetTestHelpers.ResolvePackagesWithJsonFileContents(
Resources.LockFileWithXProjReference,
".NETFramework,Version=v4.5.2",
"win",
projectReferencesCreatingPackages: new[] { referenceToXProj });
Assert.Empty(result.Analyzers);
AssertHelpers.PathEndsWith(@"XProjOutputDirectory\net452\XProjClassLib.dll", result.CopyLocalItems.Single().ItemSpec);
AssertHelpers.PathEndsWith(@"XProjOutputDirectory\net452\XProjClassLib.dll", result.References.Single().ItemSpec);
Assert.All(result.References, r => Assert.Equal(ResolveNuGetPackageAssets.NuGetSourceType_Project, r.GetMetadata(ResolveNuGetPackageAssets.NuGetSourceType)));
Assert.Empty(result.ReferencedPackages);
}
[Fact]
public void ProjectReferenceToCSProjWithoutAssetsAndNoPathSucceeds()
{

View File

@ -116,33 +116,5 @@ namespace Microsoft.NuGet.Build.Tasks.Tests.ProjectReferences {
return ResourceManager.GetString("LockFileWithCSProjReference", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {
/// &quot;locked&quot;: false,
/// &quot;version&quot;: 2,
/// &quot;targets&quot;: {
/// &quot;.NETFramework,Version=v4.5.2&quot;: {
/// &quot;XProjClassLib/1.0.0&quot;: {
/// &quot;type&quot;: &quot;project&quot;,
/// &quot;framework&quot;: &quot;.NETFramework,Version=v4.5.2&quot;,
/// &quot;compile&quot;: {
/// &quot;net452/XProjClassLib.dll&quot;: { }
/// },
/// &quot;runtime&quot;: {
/// &quot;net452/XProjClassLib.dll&quot;: { }
/// }
/// }
/// },
/// &quot;.NETFramework,Version=v4.5.2/win&quot;: {
/// &quot;XProjClassLib/1.0.0&quot;: {
/// &quot;type&quot;: &quot;project&quot;,
/// &quot;framework&quot;: &quot;.NETFram [rest of string was truncated]&quot;;.
/// </summary>
internal static string LockFileWithXProjReference {
get {
return ResourceManager.GetString("LockFileWithXProjReference", resourceCulture);
}
}
}
}

View File

@ -124,7 +124,4 @@
<data name="LockFileWithCSProjReference" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>lockfilewithcsprojreference.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="LockFileWithXProjReference" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>lockfilewithxprojreference.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root>

View File

@ -387,5 +387,42 @@ namespace Microsoft.NuGet.Build.Tasks.Tests
AssertHelpers.AssertConsistentTargetPaths(result.CopyLocalItems);
}
[Fact]
public static void MultipleProjectFileDependencyGroups()
{
var resultFor45 = NuGetTestHelpers.ResolvePackagesWithJsonFileContents(
Json.Json.MultipleProjectFileDependencyGroups,
targetMoniker: ".NETFramework,Version=v4.5",
runtimeIdentifier: "win",
allowFallbackOnTargetSelection: true);
var packageNames = resultFor45.ReferencedPackages.Select(t => t.ItemSpec);
Assert.Equal("Newtonsoft.Json", packageNames.Single());
var resultFor46 = NuGetTestHelpers.ResolvePackagesWithJsonFileContents(
Json.Json.MultipleProjectFileDependencyGroups,
targetMoniker: ".NETFramework,Version=v4.6",
runtimeIdentifier: "win",
allowFallbackOnTargetSelection: true);
AssertHelpers.AssertCountOf(1, resultFor46.ReferencedPackages);
packageNames = resultFor46.ReferencedPackages.Select(t => t.ItemSpec);
Assert.Contains("FluentAssertions", packageNames);
}
[Fact]
public static void ProjectsNotIncludedInReferences()
{
var result = NuGetTestHelpers.ResolvePackagesWithJsonFileContents(
Json.Json.ProjectDependency,
targetMoniker: ".NETFramework,Version=v4.5.2",
runtimeIdentifier: "win");
Assert.DoesNotContain("ClassLibrary1", result.ReferencedPackages.Select(t => t.ItemSpec));
}
}
}

View File

@ -13,5 +13,11 @@ Copyright (c) .NET Foundation. All rights reserved.
<PropertyGroup>
<NuGetTargets Condition="'$(NuGetTargets)'==''">$(MSBuildExtensionsPath)\Microsoft\NuGet\Microsoft.NuGet.targets</NuGetTargets>
</PropertyGroup>
<Import Condition="Exists('$(NuGetTargets)')" Project="$(NuGetTargets)" />
<Import Condition="Exists('$(NuGetTargets)') and '$(SkipImportNuGetBuildTargets)' != 'true'" Project="$(NuGetTargets)" />
<!-- Import NuGet.targets for Restore -->
<PropertyGroup>
<NuGetRestoreTargets Condition="'$(NuGetRestoreTargets)'==''">$(MSBuildExtensionsPath)\NuGet.targets</NuGetRestoreTargets>
</PropertyGroup>
<Import Condition="Exists('$(NuGetRestoreTargets)')" Project="$(NuGetRestoreTargets)" />
</Project>

View File

@ -13,5 +13,5 @@ Copyright (c) .NET Foundation. All rights reserved.
<PropertyGroup>
<NuGetProps Condition="'$(NuGetProps)'==''">$(MSBuildExtensionsPath)\Microsoft\NuGet\Microsoft.NuGet.props</NuGetProps>
</PropertyGroup>
<Import Condition="Exists('$(NuGetProps)')" Project="$(NuGetProps)" />
<Import Condition="Exists('$(NuGetProps)') and '$(SkipImportNuGetProps)' != 'true'" Project="$(NuGetProps)" />
</Project>

View File

@ -0,0 +1,18 @@
<!--
***********************************************************************************************
Microsoft.NuGet.Solution.ImportAfter.targets
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
Copyright (c) .NET Foundation. All rights reserved.
***********************************************************************************************
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Import NuGet.targets for solution Restore -->
<PropertyGroup>
<NuGetRestoreTargets Condition="'$(NuGetRestoreTargets)'==''">$(MSBuildExtensionsPath)\..\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets</NuGetRestoreTargets>
</PropertyGroup>
<Import Condition="Exists('$(NuGetRestoreTargets)')" Project="$(NuGetRestoreTargets)" />
</Project>

View File

@ -80,4 +80,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

View File

@ -12,10 +12,59 @@ Copyright (c) .NET Foundation. All rights reserved.
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="Microsoft.NuGet.Build.Tasks.ResolveNuGetPackageAssets" AssemblyFile="Microsoft.NuGet.Build.Tasks.dll" />
<PropertyGroup Condition="'$(ProjectLockFile)' == ''">
<_ProjectSpecificProjectJsonFile>$(MSBuildProjectName).project.json</_ProjectSpecificProjectJsonFile>
<ProjectLockFile Condition="Exists('$(_ProjectSpecificProjectJsonFile)')">$(MSBuildProjectName).project.lock.json</ProjectLockFile>
<ProjectLockFile Condition="!Exists('$(_ProjectSpecificProjectJsonFile)')">project.lock.json</ProjectLockFile>
<!--
Identify the project asset/lock file in following order:
1. If ProjectAssetsFile exists, then simply use it since it means project uses PackageReference
2. If ProjectLockFile already defined, then use it instead of constructing our own
3. Construct our own project lock file for that first check for <ProjectName>.project.json file
4. And lastly check for project.json file existence, and use project.lock.json file
If none of these conditions satisfy then these NuGet build targets will not be executed.
-->
<Choose>
<When Condition="'$(ProjectAssetsFile)' != ''">
<!-- The ProjectAssetsFile has been specified which means it uses PackageReference, so use that. -->
<PropertyGroup>
<ProjectLockFile>$(ProjectAssetsFile)</ProjectLockFile>
</PropertyGroup>
</When>
<When Condition="'$(RestoreProjectStyle)' == 'PackageReference'">
<!-- The RestoreProjectStyle property has been specified to PackageReference, so use that. -->
<PropertyGroup>
<ProjectLockFile>$(BaseIntermediateOutputPath)project.assets.json</ProjectLockFile>
</PropertyGroup>
</When>
<When Condition="'$(ProjectLockFile)' != ''">
<!-- The ProjectLockFile has been specified; don't compute it. -->
</When>
<When Condition="Exists('$(MSBuildProjectName).project.json')">
<!-- There's a MyProj.project.json file, so use MyProj.project.lock.json. -->
<PropertyGroup>
<ProjectLockFile>$(MSBuildProjectName).project.lock.json</ProjectLockFile>
</PropertyGroup>
</When>
<When Condition="Exists('project.json')">
<!-- There's a project.json file, so use project.lock.json. -->
<PropertyGroup>
<ProjectLockFile>project.lock.json</ProjectLockFile>
</PropertyGroup>
</When>
<Otherwise>
<!-- No assets or lock file provided at all, so fallback to project.assets.json file.-->
<PropertyGroup>
<ProjectLockFile>$(BaseIntermediateOutputPath)project.assets.json</ProjectLockFile>
</PropertyGroup>
</Otherwise>
</Choose>
<!-- Add to MSBuildAllProjects in order to better support incremental builds. -->
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<PropertyGroup>
@ -28,7 +77,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<NuGetTargetMoniker Condition="'$(NuGetTargetMoniker)' == '' AND '$(UseTargetPlatformAsNuGetTargetMoniker)' == 'true'">$(TargetPlatformIdentifier),Version=v$([System.Version]::Parse('$(TargetPlatformMinVersion)').ToString(3))</NuGetTargetMoniker>
<NuGetTargetMoniker Condition="'$(NuGetTargetMoniker)' == '' AND '$(UseTargetPlatformAsNuGetTargetMoniker)' != 'true'">$(TargetFrameworkMoniker)</NuGetTargetMoniker>
<CopyNuGetImplementations Condition="'$(CopyNuGetImplementations)' == '' and (('$(OutputType)' != 'library' and ('$(OutputType)' != 'winmdobj' or '$(AppxPackage)' == 'true')) or '$(TargetFrameworkIdentifier)' == '.NETFramework')">true</CopyNuGetImplementations>
<CopyNuGetImplementations Condition="'$(CopyNuGetImplementations)' == '' and (('$(OutputType)' != 'library' and '$(OutputType)' != 'winmdobj') or ('$(AppxPackage)' == 'true') or '$(TargetFrameworkIdentifier)' == '.NETFramework')">true</CopyNuGetImplementations>
<IncludeFrameworkReferencesFromNuGet Condition="'$(IncludeFrameworkReferencesFromNuGet)' == ''">true</IncludeFrameworkReferencesFromNuGet>
<_NuGetRuntimeIdentifierPlatformTargetSuffix Condition="'$(PlatformTarget)' != '' and '$(PlatformTarget)' != 'AnyCPU'">-$(PlatformTarget.ToLower())</_NuGetRuntimeIdentifierPlatformTargetSuffix>
@ -41,6 +90,11 @@ Copyright (c) .NET Foundation. All rights reserved.
<NuGetRuntimeIdentifier Condition="'$(UseDotNetNativeToolchain)' == 'true'">$(_NuGetRuntimeIdentifierWithoutAot)-aot</NuGetRuntimeIdentifier>
</PropertyGroup>
<!-- If RuntimeIdentifiers weren't already specified for non-UAP projects, then generate it -->
<PropertyGroup Condition="'$(BaseNuGetRuntimeIdentifier)' == 'win' and '$(NuGetRuntimeIdentifier)' != '' and '$(RuntimeIdentifiers)' == '' and '$(RuntimeIdentifier)' == ''">
<RuntimeIdentifiers>win;win-x86;win-x64</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
<!-- If we are resolving from project.lock.json, we need to consider any edit to it as something that forces a rebuild -->
<CustomAdditionalCompileInputs Include="$(ProjectLockFile)" Condition="'$(ResolveNuGetPackages)' == 'true' and Exists('$(ProjectLockFile)')" />
@ -117,25 +171,9 @@ Copyright (c) .NET Foundation. All rights reserved.
<ResolveNuGetPackageAssetsDependsOn Condition="'$(ImplicitlyExpandTargetFramework)' == 'true'">$(ResolveNuGetPackageAssetsDependsOn);ImplicitlyExpandTargetFramework</ResolveNuGetPackageAssetsDependsOn>
</PropertyGroup>
<Target Name="ResolveNuGetPackageAssets" DependsOnTargets="$(ResolveNuGetPackageAssetsDependsOn)" Condition="'$(ResolveNuGetPackages)' == 'true' and exists('$(ProjectLockFile)')">
<!-- We need to figure out the output path of any dependent xproj projects -->
<MSBuild
Projects="@(_MSBuildProjectReferenceExistent)"
Targets="GetTargetDir"
BuildInParallel="$(BuildInParallel)"
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform)"
RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)"
Condition="'%(_MSBuildProjectReferenceExistent.Extension)' == '.xproj'">
<Output TaskParameter="TargetOutputs" ItemName="_XProjTargetDirs" />
</MSBuild>
<!-- The items in _XProjTargetDirs have the target directories as the main itemspecs and the originating project as metadata; reverse them -->
<ItemGroup>
<ProjectReferenceCreatingPackage Include="%(_XProjTargetDirs.OriginalItemSpec)">
<OutputBasePath>%(_XProjTargetDirs.Identity)</OutputBasePath>
</ProjectReferenceCreatingPackage>
</ItemGroup>
<Target Name="ResolveNuGetPackageAssets"
DependsOnTargets="$(ResolveNuGetPackageAssetsDependsOn)"
Condition="'$(ResolveNuGetPackages)' == 'true' and exists('$(ProjectLockFile)')">
<ResolveNuGetPackageAssets AllowFallbackOnTargetSelection="$(DesignTimeBuild)"
ContinueOnError="$(ContinueOnError)"
@ -144,7 +182,6 @@ Copyright (c) .NET Foundation. All rights reserved.
RuntimeIdentifier="$(NuGetRuntimeIdentifier)"
ProjectLanguage="$(Language)"
ProjectLockFile="$(ProjectLockFile)"
ProjectReferencesCreatingPackages="@(ProjectReferenceCreatingPackage)"
ContentPreprocessorValues="@(NuGetPreprocessorValue)"
ContentPreprocessorOutputDirectory="$(IntermediateOutputPath)\NuGet"
TargetMonikers="$(NuGetTargetMoniker);$(_NuGetTargetFallbackMoniker)">
@ -188,7 +225,10 @@ Copyright (c) .NET Foundation. All rights reserved.
</CreateItem>
</Target>
<Target Name="RuntimeImplementationProjectOutputGroup" Returns="@(RuntimeImplementationProjectOutputGroupOutput)" Condition="'$(ResolveNuGetPackages)' == 'true' and exists('$(ProjectLockFile)')">
<Target Name="RuntimeImplementationProjectOutputGroup"
Returns="@(RuntimeImplementationProjectOutputGroupOutput)"
Condition="'$(ResolveNuGetPackages)' == 'true' and exists('$(ProjectLockFile)')">
<!-- This output group must contain the implementation assemblies for the host (i.e. design time) environment, not the
target environment. Thus, we explicitly pass the RuntimeIdentifier that doesn't have the -aot suffix -->
<ResolveNuGetPackageAssets AllowFallbackOnTargetSelection="$(DesignTimeBuild)"
@ -224,6 +264,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<PropertyGroup>
<_PackagingOutputsIncludesFramework Condition="'%(PackagingOutputs.FileName)%(PackagingOutputs.Extension)' == 'System.Runtime.dll'">true</_PackagingOutputsIncludesFramework>
<_AppContainsManagedCodeForInjection Condition="'%(PackagingOutputs.Identity)' == '$(_TargetPlatformSdkDir)UnionMetadata\Windows.winmd'">true</_AppContainsManagedCodeForInjection>
<_AppContainsManagedCodeForInjection Condition="'%(PackagingOutputs.Identity)' == '$(WindowsSDK_UnionMetadataPath)\Windows.winmd'">true</_AppContainsManagedCodeForInjection>
</PropertyGroup>
<PropertyGroup>
@ -231,11 +272,15 @@ Copyright (c) .NET Foundation. All rights reserved.
</PropertyGroup>
</Target>
<Target Name="InjectNetCoreFrameworkBlockIfLockFileExists" AfterTargets="ComputeNetCoreFrameworkInjectionParameters" Condition="'$(_NetCoreFrameworkInjectionNeeded)' == 'true' and '$(ResolveNuGetPackages)' == 'true' and Exists('$(ProjectLockFile)')">
<Target Name="InjectNetCoreFrameworkBlockIfLockFileExists"
AfterTargets="ComputeNetCoreFrameworkInjectionParameters"
Condition="'$(_NetCoreFrameworkInjectionNeeded)' == 'true' and '$(ResolveNuGetPackages)' == 'true' and exists('$(ProjectLockFile)')">
<Error Text="One of your dependencies requires the .NET Framework, but the .NET Framework could not be found in the NuGet packages installed in this project. Please install the appropriate .NET Framework packages required by your dependency." />
</Target>
<Target Name="InjectNetCoreFramework" AfterTargets="ComputeNetCoreFrameworkInjectionParameters" Condition="'$(_NetCoreFrameworkInjectionNeeded)' == 'true' and ('$(ResolveNuGetPackages)' != 'true' or !Exists('$(ProjectLockFile)'))">
<Target Name="InjectNetCoreFramework"
AfterTargets="ComputeNetCoreFrameworkInjectionParameters"
Condition="'$(_NetCoreFrameworkInjectionNeeded)' == 'true' and ('$(ResolveNuGetPackages)' != 'true' or !Exists('$(ProjectLockFile)'))">
<GetReferenceAssemblyPaths TargetFrameworkMoniker="$(NuGetTargetFrameworkMonikerToInject)" Condition="'$(FrameworkInjectionLockFile)' == ''">
<Output TaskParameter="ReferenceAssemblyPaths" ItemName="_NuGetInjectionSourceDirectories" />
</GetReferenceAssemblyPaths>

View File

@ -23,11 +23,10 @@ namespace Microsoft.NuGet.Build.Tasks
/// </summary>
private readonly Lazy<string> _fullPackagePath;
public NuGetPackageObject(string id, string version, bool isProject, Func<string> fullPackagePathGenerator, JObject targetObject, JObject libraryObject)
public NuGetPackageObject(string id, string version, Func<string> fullPackagePathGenerator, JObject targetObject, JObject libraryObject)
{
Id = id;
Version = version;
IsProject = isProject;
_fullPackagePath = new Lazy<string>(fullPackagePathGenerator);
TargetObject = targetObject;
LibraryObject = libraryObject;
@ -35,7 +34,6 @@ namespace Microsoft.NuGet.Build.Tasks
public string Id { get; }
public string Version { get; }
public bool IsProject { get; }
/// <summary>
/// The JSON object from the "targets" section in the project.lock.json for this package.

View File

@ -23,7 +23,6 @@ namespace Microsoft.NuGet.Build.Tasks
internal const string NuGetPackageVersionMetadata = "NuGetPackageVersion";
internal const string NuGetIsFrameworkReference = "NuGetIsFrameworkReference";
internal const string NuGetSourceType = "NuGetSourceType";
internal const string NuGetSourceType_Project = "Project";
internal const string NuGetSourceType_Package = "Package";
internal const string ReferenceImplementationMetadata = "Implementation";
@ -46,8 +45,6 @@ namespace Microsoft.NuGet.Build.Tasks
private readonly List<string> _packageFolders = new List<string>();
private readonly Dictionary<string, string> _projectReferencesToOutputBasePaths = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
#region UnitTestSupport
private readonly FileExists _fileExists = new FileExists(File.Exists);
private readonly TryGetRuntimeVersion _tryGetRuntimeVersion = new TryGetRuntimeVersion(TryGetRuntimeVersion);
@ -142,15 +139,6 @@ namespace Microsoft.NuGet.Build.Tasks
get; set;
}
/// <summary>
/// A list of project references that are creating packages as listed in the lock file. The OutputPath metadata should
/// set on each of these items, which is used by the task to construct full output paths to assets.
/// </summary>
public ITaskItem[] ProjectReferencesCreatingPackages
{
get; set;
}
/// <summary>
/// The base output directory where the temporary, preprocessed files should be written to.
/// </summary>
@ -238,7 +226,6 @@ namespace Microsoft.NuGet.Build.Tasks
PopulatePackageFolders(lockFile);
PopulateProjectReferenceMaps();
GetReferences(lockFile);
GetCopyLocalItems(lockFile);
GetAnalyzers(lockFile);
@ -281,23 +268,6 @@ namespace Microsoft.NuGet.Build.Tasks
}
}
private void PopulateProjectReferenceMaps()
{
foreach (var projectReference in ProjectReferencesCreatingPackages ?? new ITaskItem[] { })
{
var fullPath = GetAbsolutePathFromProjectRelativePath(projectReference.ItemSpec);
if (_projectReferencesToOutputBasePaths.ContainsKey(fullPath))
{
Log.LogWarningFromResources(nameof(Strings.DuplicateProjectReference), fullPath, nameof(ProjectReferencesCreatingPackages));
}
else
{
var outputPath = projectReference.GetMetadata("OutputBasePath");
_projectReferencesToOutputBasePaths.Add(fullPath, outputPath);
}
}
}
private void GetReferences(JObject lockFile)
{
var target = GetTargetOrAttemptFallback(lockFile, needsRuntimeIdentifier: false);
@ -820,7 +790,7 @@ namespace Microsoft.NuGet.Build.Tasks
item.SetMetadata("Private", "false");
item.SetMetadata(NuGetIsFrameworkReference, "false");
item.SetMetadata(NuGetSourceType, package.IsProject ? NuGetSourceType_Project : NuGetSourceType_Package);
item.SetMetadata(NuGetSourceType, NuGetSourceType_Package);
items.Add(item);
@ -881,16 +851,83 @@ namespace Microsoft.NuGet.Build.Tasks
private void GetReferencedPackages(JObject lockFile)
{
var projectFileDependencyGroups = (JObject)lockFile["projectFileDependencyGroups"];
var projectFileDependencies = (JArray)projectFileDependencyGroups[""];
var targets = (JObject)lockFile["targets"];
foreach (var packageDependency in projectFileDependencies.Select(v => (string)v))
string targetMoniker = null;
foreach (var preferredTargetMoniker in TargetMonikers)
{
int firstSpace = packageDependency.IndexOf(' ');
var preferredTargetMonikerWithOptionalRuntimeIdentifier = GetTargetMonikerWithOptionalRuntimeIdentifier(preferredTargetMoniker, needsRuntimeIdentifier: false);
var target = (JObject)targets[preferredTargetMonikerWithOptionalRuntimeIdentifier];
if (firstSpace > -1)
if (target != null)
{
_referencedPackages.Add(new TaskItem(packageDependency.Substring(0, firstSpace)));
targetMoniker = preferredTargetMonikerWithOptionalRuntimeIdentifier;
break;
}
}
var projectFileDependencyGroups = (JObject)lockFile["projectFileDependencyGroups"];
var allPackageNames = GetAllPackageNames(lockFile);
if (targetMoniker != null)
{
var targetSpecificDependencies = (JArray)projectFileDependencyGroups[targetMoniker];
if (targetSpecificDependencies != null)
{
AddReferencedPackages(targetSpecificDependencies, allPackageNames);
}
}
var universalDependencies = (JArray)projectFileDependencyGroups[""];
if (universalDependencies != null)
{
AddReferencedPackages(universalDependencies, allPackageNames);
}
}
/// <summary>
/// Returns the set of all the package names (not including version numbers)
/// in the "libraries" section of the assets/lock file. Note that this includes
/// only proper packages; projects are specifically excluded.
/// </summary>
private static SortedSet<string> GetAllPackageNames(JObject lockFile)
{
var allPackageNames = new SortedSet<string>();
var libraries = (JObject)lockFile["libraries"];
foreach (var library in libraries)
{
var libraryObject = (JObject)library.Value;
string type = (string)libraryObject["type"];
if (type != null &&
type.Equals("project", StringComparison.OrdinalIgnoreCase))
{
continue;
}
string name, version;
SplitPackageName(library.Key, out name, out version);
allPackageNames.Add(name);
}
return allPackageNames;
}
/// <summary>
/// Given a set of dependencies, identities the packages and adds their names to <see cref="_referencedPackages"/>.
/// </summary>
private void AddReferencedPackages(JArray packageDependencies, SortedSet<string> allPackageNames)
{
foreach (var packageDependency in packageDependencies.Select(v => (string)v))
{
// Strip the version, if any, from the dependency.
int firstSpace = packageDependency.IndexOf(' ');
string packageName = firstSpace > -1
? packageDependency.Substring(0, firstSpace)
: packageDependency;
if (allPackageNames.Contains(packageName))
{
_referencedPackages.Add(new TaskItem(packageName));
}
}
}
@ -916,10 +953,8 @@ namespace Microsoft.NuGet.Build.Tasks
{
foreach (var package in target)
{
var nameParts = package.Key.Split('/');
var id = nameParts[0];
var version = nameParts[1];
bool isProject = false;
string id, version;
SplitPackageName(package.Key, out id, out version);
var libraryObject = (JObject)lockFile["libraries"][package.Key];
@ -931,38 +966,26 @@ namespace Microsoft.NuGet.Build.Tasks
}
// If this is a project then we need to figure out it's relative output path
if ((string)libraryObject["type"] == "project")
if ("project".Equals((string)libraryObject["type"], StringComparison.OrdinalIgnoreCase))
{
isProject = true;
fullPackagePathGenerator = () =>
{
var relativeMSBuildProjectPath = (string)libraryObject["msbuildProject"];
if (string.IsNullOrEmpty(relativeMSBuildProjectPath))
{
throw new ExceptionFromResource(nameof(Strings.MissingMSBuildPathInProjectPackage), id);
}
var absoluteMSBuildProjectPath = GetAbsolutePathFromProjectRelativePath(relativeMSBuildProjectPath);
string fullPackagePath;
if (!_projectReferencesToOutputBasePaths.TryGetValue(absoluteMSBuildProjectPath, out fullPackagePath))
{
throw new ExceptionFromResource(nameof(Strings.MissingProjectReference), absoluteMSBuildProjectPath, nameof(ProjectReferencesCreatingPackages));
}
return fullPackagePath;
};
continue;
}
else
{
fullPackagePathGenerator = () => GetNuGetPackagePath(id, version);
}
yield return new NuGetPackageObject(id, version, isProject, fullPackagePathGenerator, (JObject)package.Value, libraryObject);
yield return new NuGetPackageObject(id, version, fullPackagePathGenerator, (JObject)package.Value, libraryObject);
}
}
private static void SplitPackageName(string key, out string id, out string version)
{
var nameParts = key.Split('/');
id = nameParts[0];
version = nameParts[1];
}
private string GetAbsolutePathFromProjectRelativePath(string path)
{
return Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Path.GetFullPath(ProjectLockFile)), path));

View File

@ -69,15 +69,6 @@ namespace Microsoft.NuGet.Build.Tasks {
}
}
/// <summary>
/// Looks up a localized string similar to The project &apos;{0}&apos; was referenced more than once in the {1} property. Ignoring all but the first..
/// </summary>
internal static string DuplicateProjectReference {
get {
return ResourceManager.GetString("DuplicateProjectReference", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Lock file {0} couldn&apos;t be found. Run a NuGet package restore to generate this file..
/// </summary>

Some files were not shown because too many files have changed in this diff Show More