Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/NuGet.BuildTasks.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnkit Mishra <anmishr@microsoft.com>2018-06-01 22:53:05 +0300
committerGitHub <noreply@github.com>2018-06-01 22:53:05 +0300
commit07fea8d162516387fe5c6a8f8022711f7646dacb (patch)
treec14a93bef1810066cf7b8eeccc451f3c676cf9df
parent0aa5091682343110f645ede1a184ee7fea127b7b (diff)
parentdbca182d8c8e72eb806d3423c0fbb54d7dfcf2c4 (diff)
Merge pull request #48 from NuGet/dev-anmishr-removetestdependency
Removing dependency on NuGet.ProjectModel
-rw-r--r--src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.Designer.cs20
-rw-r--r--src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.resx6
-rw-r--r--src/Microsoft.NuGet.Build.Tasks.Tests/Json/WithTargets.assets.json51
-rw-r--r--src/Microsoft.NuGet.Build.Tasks.Tests/Json/WithoutTargets.assets.json39
-rw-r--r--src/Microsoft.NuGet.Build.Tasks.Tests/ReferenceResolutionTests.cs108
5 files changed, 121 insertions, 103 deletions
diff --git a/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.Designer.cs b/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.Designer.cs
index e75ea94..9137dec 100644
--- a/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.Designer.cs
+++ b/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.Designer.cs
@@ -358,5 +358,25 @@ namespace Microsoft.NuGet.Build.Tasks.Tests.Json {
return ResourceManager.GetString("Win10_xunit", resourceCulture);
}
}
+
+ /// <summary>
+ /// Looks up a localized resource of type System.Byte[].
+ /// </summary>
+ internal static byte[] WithoutTargets_assets {
+ get {
+ object obj = ResourceManager.GetObject("WithoutTargets_assets", resourceCulture);
+ return ((byte[])(obj));
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized resource of type System.Byte[].
+ /// </summary>
+ internal static byte[] WithTargets_assets {
+ get {
+ object obj = ResourceManager.GetObject("WithTargets_assets", resourceCulture);
+ return ((byte[])(obj));
+ }
+ }
}
}
diff --git a/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.resx b/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.resx
index 993a1fe..0286e1b 100644
--- a/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.resx
+++ b/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.resx
@@ -151,4 +151,10 @@
<data name="MultipleProjectFileDependencyGroups_CaseMismatch" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>multipleprojectfiledependencygroups_casemismatch.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
+ <data name="WithoutTargets_assets" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>WithoutTargets.assets.json;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </data>
+ <data name="WithTargets_assets" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>WithTargets.assets.json;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </data>
</root> \ No newline at end of file
diff --git a/src/Microsoft.NuGet.Build.Tasks.Tests/Json/WithTargets.assets.json b/src/Microsoft.NuGet.Build.Tasks.Tests/Json/WithTargets.assets.json
new file mode 100644
index 0000000..bef673f
--- /dev/null
+++ b/src/Microsoft.NuGet.Build.Tasks.Tests/Json/WithTargets.assets.json
@@ -0,0 +1,51 @@
+{
+ "version": 2,
+ "targets": {
+ ".NETFramework,Version=v4.5": {
+ "System.Text/4.5.0": {
+ "type": "package",
+ "dependencies": {
+ "System": "4.5.0"
+ },
+ "compile": {
+ "ref/net45/System.Text.dll": {}
+ }
+ }
+ }
+ },
+ "libraries": {
+ "System.Text/4.5.0": {
+ "type": "package",
+ "path": "system.text/4.5.0"
+ }
+ },
+ "projectFileDependencyGroups": {},
+ "project": {
+ "version": "1.0.0",
+ "restore": {
+ "projectUniqueName": "X:\\ProjectPath\\ProjectPath.csproj",
+ "projectName": "ProjectPath",
+ "projectPath": "X:\\ProjectPath\\ProjectPath.csproj",
+ "outputPath": "X:\\ProjectPath\\obj\\",
+ "projectStyle": "PackageReference",
+ "originalTargetFrameworks": [
+ "net45"
+ ],
+ "frameworks": {
+ "net45": {
+ "projectReferences": {}
+ }
+ }
+ },
+ "frameworks": {
+ "net45": {
+ "dependencies": {
+ "System.Text": {
+ "target": "Package",
+ "version": "[4.5.0, )"
+ }
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/Microsoft.NuGet.Build.Tasks.Tests/Json/WithoutTargets.assets.json b/src/Microsoft.NuGet.Build.Tasks.Tests/Json/WithoutTargets.assets.json
new file mode 100644
index 0000000..4eae5df
--- /dev/null
+++ b/src/Microsoft.NuGet.Build.Tasks.Tests/Json/WithoutTargets.assets.json
@@ -0,0 +1,39 @@
+{
+ "version": 2,
+ "targets": {},
+ "libraries": {
+ "System.Text/4.5.0": {
+ "type": "package",
+ "path": "system.text/4.5.0"
+ }
+ },
+ "projectFileDependencyGroups": {},
+ "project": {
+ "version": "1.0.0",
+ "restore": {
+ "projectUniqueName": "X:\\ProjectPath\\ProjectPath.csproj",
+ "projectName": "ProjectPath",
+ "projectPath": "X:\\ProjectPath\\ProjectPath.csproj",
+ "outputPath": "X:\\ProjectPath\\obj\\",
+ "projectStyle": "PackageReference",
+ "originalTargetFrameworks": [
+ "net45"
+ ],
+ "frameworks": {
+ "net45": {
+ "projectReferences": {}
+ }
+ }
+ },
+ "frameworks": {
+ "net45": {
+ "dependencies": {
+ "System.Text": {
+ "target": "Package",
+ "version": "[4.5.0, )"
+ }
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/Microsoft.NuGet.Build.Tasks.Tests/ReferenceResolutionTests.cs b/src/Microsoft.NuGet.Build.Tasks.Tests/ReferenceResolutionTests.cs
index 4990535..180c94f 100644
--- a/src/Microsoft.NuGet.Build.Tasks.Tests/ReferenceResolutionTests.cs
+++ b/src/Microsoft.NuGet.Build.Tasks.Tests/ReferenceResolutionTests.cs
@@ -2,16 +2,10 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using System.Collections.Generic;
-using System.Diagnostics;
using System.IO;
using System.Linq;
+using System.Text;
using Microsoft.NuGet.Build.Tasks.Tests.Helpers;
-using NuGet.Frameworks;
-using NuGet.LibraryModel;
-using NuGet.Packaging.Core;
-using NuGet.ProjectModel;
-using NuGet.Versioning;
using Xunit;
namespace Microsoft.NuGet.Build.Tasks.Tests
@@ -117,16 +111,12 @@ namespace Microsoft.NuGet.Build.Tasks.Tests
[Fact]
public static void TestReferenceResolutionWithMissingRuntimeIDAndNoFallbackInProjectCsproj()
{
- var lockFile = GenerateLockFileWithTarget();
-
using (var tempRoot = new TempRoot())
using (var disposableFile = new DisposableFile(tempRoot.CreateFile(extension: "assets.json").Path))
{
- new LockFileFormat().Write(disposableFile.Path, lockFile);
-
var exception = Assert.Throws<ExceptionFromResource>(() =>
NuGetTestHelpers.ResolvePackagesWithJsonFileContents(
- File.ReadAllText(disposableFile.Path),
+ Encoding.UTF8.GetString(Json.Json.WithTargets_assets, 0, Json.Json.WithTargets_assets.Length),
targetMoniker: ".NETFramework,Version=v4.5",
runtimeIdentifier: "missing-runtime-identifier",
allowFallbackOnTargetSelection: false,
@@ -169,16 +159,12 @@ namespace Microsoft.NuGet.Build.Tasks.Tests
[Fact]
public static void TestReferenceResolutionWithMissingTargetFrameworkAndNoFallbackInProjectCsproj()
{
- var lockFile = GenerateLockFileWithoutTarget();
-
using (var tempRoot = new TempRoot())
using (var disposableFile = new DisposableFile(tempRoot.CreateFile(extension: "assets.json").Path))
{
- new LockFileFormat().Write(disposableFile.Path, lockFile);
-
var exception = Assert.Throws<ExceptionFromResource>(() =>
NuGetTestHelpers.ResolvePackagesWithJsonFileContents(
- File.ReadAllText(disposableFile.Path),
+ Encoding.UTF8.GetString(Json.Json.WithoutTargets_assets, 0, Json.Json.WithoutTargets_assets.Length),
targetMoniker: "Missing,Version=1.0",
runtimeIdentifier: "missing-runtime-identifier",
allowFallbackOnTargetSelection: false,
@@ -206,15 +192,11 @@ namespace Microsoft.NuGet.Build.Tasks.Tests
[Fact]
public static void TestReferenceResolutionWithMissingTargetFrameworkAndFallbackInProjectCsproj()
{
- var lockFile = GenerateLockFileWithTarget();
-
using (var tempRoot = new TempRoot())
using (var disposableFile = new DisposableFile(tempRoot.CreateFile(extension: "assets.json").Path))
{
- new LockFileFormat().Write(disposableFile.Path, lockFile);
-
var result = NuGetTestHelpers.ResolvePackagesWithJsonFileContents(
- File.ReadAllText(disposableFile.Path),
+ Encoding.UTF8.GetString(Json.Json.WithTargets_assets, 0, Json.Json.WithTargets_assets.Length),
targetMoniker: "MissingFrameworkMoniker,Version=v42.0",
runtimeIdentifier: "",
allowFallbackOnTargetSelection: true,
@@ -231,16 +213,12 @@ namespace Microsoft.NuGet.Build.Tasks.Tests
[InlineData(false, nameof(Strings.NoTargetsInLockFileForProjectFile))]
public static void TestReferenceResolutionWithMissingTargets(bool isProjectJsonBased, string errorResourceName)
{
- var lockFile = GenerateLockFileWithoutTarget();
-
using (var tempRoot = new TempRoot())
using (var disposableFile = new DisposableFile(tempRoot.CreateFile(extension: "assets.json").Path))
{
- new LockFileFormat().Write(disposableFile.Path, lockFile);
-
var exception = Assert.Throws<ExceptionFromResource>(() =>
NuGetTestHelpers.ResolvePackagesWithJsonFileContents(
- File.ReadAllText(disposableFile.Path),
+ Encoding.UTF8.GetString(Json.Json.WithoutTargets_assets, 0, Json.Json.WithoutTargets_assets.Length),
targetMoniker: "MissingFrameworkMoniker,Version=v42.0",
runtimeIdentifier: "",
allowFallbackOnTargetSelection: true,
@@ -566,81 +544,5 @@ namespace Microsoft.NuGet.Build.Tasks.Tests
Assert.DoesNotContain("ClassLibrary1", result.ReferencedPackages.Select(t => t.ItemSpec));
}
- private static LockFile GenerateLockFileWithoutTarget()
- {
- return new LockFile
- {
- Version = 2,
- PackageSpec = new PackageSpec(new TargetFrameworkInformation[]
- {
- new TargetFrameworkInformation
- {
- FrameworkName = FrameworkConstants.CommonFrameworks.Net45,
- Dependencies = new[]
- {
- new LibraryDependency
- {
- LibraryRange = new LibraryRange(
- "System.Text",
- new VersionRange(
- minVersion: new NuGetVersion("4.5.0"),
- originalString: "4.5.0"),
- LibraryDependencyTarget.Package)
- }
- }
- }
- })
- {
- Version = new NuGetVersion("1.0.0"),
- RestoreMetadata = new ProjectRestoreMetadata
- {
- ProjectUniqueName = @"X:\ProjectPath\ProjectPath.csproj",
- ProjectName = "ProjectPath",
- ProjectPath = @"X:\ProjectPath\ProjectPath.csproj",
- OutputPath = @"X:\ProjectPath\obj\",
- ProjectStyle = ProjectStyle.PackageReference,
- OriginalTargetFrameworks = new string[] { "net45" },
- TargetFrameworks = new List<ProjectRestoreMetadataFrameworkInfo>
- {
- new ProjectRestoreMetadataFrameworkInfo(NuGetFramework.Parse("net45"))
- }
- }
- },
- Libraries = new LockFileLibrary[]
- {
- new LockFileLibrary()
- {
- Name = "System.Text",
- Version = NuGetVersion.Parse("4.5.0"),
- Path = "system.text/4.5.0",
- Type = LibraryType.Package
- }
- }
- };
- }
-
- private static LockFile GenerateLockFileWithTarget()
- {
- var lockFile = GenerateLockFileWithoutTarget();
-
- var target = new LockFileTarget()
- {
- TargetFramework = FrameworkConstants.CommonFrameworks.Net45
- };
-
- var targetLib = new LockFileTargetLibrary()
- {
- Name = "System.Text",
- Version = new NuGetVersion("4.5.0"),
- Type = LibraryType.Package
- };
-
- targetLib.Dependencies.Add(new PackageDependency("System", new VersionRange(NuGetVersion.Parse("4.5.0"))));
- targetLib.CompileTimeAssemblies.Add(new LockFileItem("ref/net45/System.Text.dll"));
- target.Libraries.Add(targetLib);
- lockFile.Targets.Add(target);
-
- return lockFile;
- }
}
}