diff --git a/src/NuGet.Clients/NuGet.SolutionRestoreManager/SolutionRestoreCommand.cs b/src/NuGet.Clients/NuGet.SolutionRestoreManager/SolutionRestoreCommand.cs
index a781fa366f0..d77b8b38ac5 100644
--- a/src/NuGet.Clients/NuGet.SolutionRestoreManager/SolutionRestoreCommand.cs
+++ b/src/NuGet.Clients/NuGet.SolutionRestoreManager/SolutionRestoreCommand.cs
@@ -5,6 +5,7 @@
using System.ComponentModel.Composition;
using System.ComponentModel.Design;
using System.Linq;
+using System.Threading;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Shell;
@@ -12,7 +13,6 @@
using NuGet.PackageManagement;
using NuGet.PackageManagement.UI;
using NuGet.PackageManagement.VisualStudio;
-using NuGet.ProjectManagement;
using NuGetConsole;
using Task = System.Threading.Tasks.Task;
@@ -41,6 +41,8 @@ internal sealed class SolutionRestoreCommand
private readonly IVsMonitorSelection _vsMonitorSelection;
private uint _solutionNotBuildingAndNotDebuggingContextCookie;
+ private Task _restoreTask = Task.CompletedTask;
+
private SolutionRestoreCommand(
IMenuCommandService commandService,
IVsMonitorSelection vsMonitorSelection,
@@ -103,25 +105,23 @@ public static async Task InitializeAsync(AsyncPackage package)
/// Event args.
private void OnRestorePackages(object sender, EventArgs args)
{
- if (!SolutionRestoreWorker.IsBusy)
- {
- SolutionRestoreWorker.Restore(SolutionRestoreRequest.ByMenu());
- }
- else
+ if (_restoreTask.IsCompleted)
{
- // QueryStatus should disable the context menu in most of the cases.
- // Except when NuGetPackage was not loaded before VS won't send QueryStatus.
- Logger.Log(MessageLevel.Info, Resources.SolutionRestoreFailed_RestoreWorkerIsBusy);
+ _restoreTask = NuGetUIThreadHelper.JoinableTaskFactory
+ .RunAsync(() => SolutionRestoreWorker.ScheduleRestoreAsync(
+ SolutionRestoreRequest.ByMenu(),
+ CancellationToken.None))
+ .Task;
}
}
private void BeforeQueryStatusForPackageRestore(object sender, EventArgs args)
{
- NuGetUIThreadHelper.JoinableTaskFactory.Run((Func)async delegate
+ NuGetUIThreadHelper.JoinableTaskFactory.Run(async delegate
{
await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
- OleMenuCommand command = (OleMenuCommand)sender;
+ var command = (OleMenuCommand)sender;
// Enable the 'Restore NuGet Packages' dialog menu
// - if the console is NOT busy executing a command, AND
@@ -130,10 +130,15 @@ private void BeforeQueryStatusForPackageRestore(object sender, EventArgs args)
// - if the solution is DPL enabled or there are NuGetProjects. This means that there loaded, supported projects
// Checking for DPL more is a temporary code until we've the capability to get nuget projects
// even in DPL mode. See https://github.com/NuGet/Home/issues/3711
- command.Enabled = !ConsoleStatus.IsBusy &&
+ command.Enabled =
+ _restoreTask.IsCompleted &&
+ !ConsoleStatus.IsBusy &&
!SolutionRestoreWorker.IsBusy &&
IsSolutionExistsAndNotDebuggingAndNotBuilding() &&
- (SolutionManager.IsSolutionDPLEnabled || Enumerable.Any(SolutionManager.GetNuGetProjects()));
+ (
+ SolutionManager.IsSolutionDPLEnabled ||
+ Enumerable.Any(SolutionManager.GetNuGetProjects())
+ );
});
}
diff --git a/src/NuGet.Clients/NuGet.SolutionRestoreManager/SolutionRestoreWorker.cs b/src/NuGet.Clients/NuGet.SolutionRestoreManager/SolutionRestoreWorker.cs
index 0360edf5ca2..b4c69fa6c63 100644
--- a/src/NuGet.Clients/NuGet.SolutionRestoreManager/SolutionRestoreWorker.cs
+++ b/src/NuGet.Clients/NuGet.SolutionRestoreManager/SolutionRestoreWorker.cs
@@ -324,11 +324,21 @@ private async Task StartBackgroundJobRunnerAsync(CancellationToken token)
while (!_pendingRequests.Value.IsCompleted
&& !token.IsCancellationRequested)
{
- SolutionRestoreRequest discard;
- if (!_pendingRequests.Value.TryTake(out discard, IdleTimeoutMs, token))
+ SolutionRestoreRequest next;
+ if (!_pendingRequests.Value.TryTake(out next, IdleTimeoutMs, token))
{
break;
}
+
+ // Upgrade request if necessary
+ if (next.RestoreSource != request.RestoreSource)
+ {
+ // there could be requests of two types: Auto-Restore or Explicit
+ // Explicit is always preferred.
+ request = new SolutionRestoreRequest(
+ next.ForceRestore || request.ForceRestore,
+ RestoreOperationSource.Explicit);
+ }
}
token.ThrowIfCancellationRequested();
diff --git a/test/EndToEnd/ProjectTemplates/NetStandardClassLibrary.zip/Class1.cs b/test/EndToEnd/ProjectTemplates/NetStandardClassLibrary.zip/Class1.cs
new file mode 100644
index 00000000000..44b75d21442
--- /dev/null
+++ b/test/EndToEnd/ProjectTemplates/NetStandardClassLibrary.zip/Class1.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace $safeprojectname$
+{
+ public class Class1
+ {
+ }
+}
diff --git a/test/EndToEnd/ProjectTemplates/NetStandardClassLibrary.zip/ClassLibrary.csproj b/test/EndToEnd/ProjectTemplates/NetStandardClassLibrary.zip/ClassLibrary.csproj
new file mode 100644
index 00000000000..40f997ebd82
--- /dev/null
+++ b/test/EndToEnd/ProjectTemplates/NetStandardClassLibrary.zip/ClassLibrary.csproj
@@ -0,0 +1,9 @@
+
+
+
+ netstandard1.4;net46
+ NuGet.TestPackage
+ 1.0.1-preview
+
+
+
\ No newline at end of file
diff --git a/test/EndToEnd/ProjectTemplates/NetStandardClassLibrary.zip/NetStandardClassLibrary.vstemplate b/test/EndToEnd/ProjectTemplates/NetStandardClassLibrary.zip/NetStandardClassLibrary.vstemplate
new file mode 100644
index 00000000000..32cc8efaaea
--- /dev/null
+++ b/test/EndToEnd/ProjectTemplates/NetStandardClassLibrary.zip/NetStandardClassLibrary.vstemplate
@@ -0,0 +1,17 @@
+
+
+
+ NetStandardClassLibrary
+ .NET Standard class library template
+ CSharp
+ 1000
+ true
+ NetStandardClassLibrary
+ true
+
+
+
+ Class1.cs
+
+
+
\ No newline at end of file
diff --git a/test/EndToEnd/tests/NetCoreProjectTests.ps1 b/test/EndToEnd/tests/NetCoreProjectTests.ps1
index 3540fedbe41..ed880c55a9a 100644
--- a/test/EndToEnd/tests/NetCoreProjectTests.ps1
+++ b/test/EndToEnd/tests/NetCoreProjectTests.ps1
@@ -3,21 +3,21 @@ function Test-NetCoreConsoleAppCreate {
# Arrange & Act
$project = New-NetCoreConsoleApp ConsoleApp
-
+
# Assert
Assert-NetCoreProjectCreation $project
}
# install package test for .net core
function Test-NetCoreConsoleAppInstallPackage {
-
+
# Arrange
$project = New-NetCoreConsoleApp ConsoleApp
$id = 'NuGet.Versioning'
$version = '3.5.0'
Assert-NetCoreProjectCreation $project
- # Act
+ # Act
Install-Package $id -ProjectName $project.Name -version $version
$project.Save($project.FullName)
Build-Solution
@@ -28,14 +28,14 @@ function Test-NetCoreConsoleAppInstallPackage {
# install and uninstall package test for .net core
function Test-NetCoreConsoleAppUninstallPackage {
-
+
# Arrange
$project = New-NetCoreConsoleApp ConsoleApp
$id = 'NuGet.Versioning'
$version = '3.5.0'
Assert-NetCoreProjectCreation $project
- # Act
+ # Act
Install-Package $id -ProjectName $project.Name -version $version
$project.Save($project.FullName)
Build-Solution
@@ -72,7 +72,7 @@ function Test-NetCoreConsoleAppInstallMultiplePackages {
# install and uninstall multiple packages test for .net core
function Test-NetCoreConsoleAppUninstallMultiplePackage {
-
+
# Arrange
$project = New-NetCoreConsoleApp ConsoleApp
$id1 = 'NuGet.Versioning'
@@ -99,7 +99,7 @@ function Test-NetCoreConsoleAppUninstallMultiplePackage {
# install and upgrade package test for .net core
function Test-NetCoreConsoleAppUpgradePackage {
-
+
# Arrange
$project = New-NetCoreConsoleApp ConsoleApp
$id = 'NuGet.Versioning'
@@ -107,7 +107,7 @@ function Test-NetCoreConsoleAppUpgradePackage {
$newVersion = '4.0.0-rc2'
Assert-NetCoreProjectCreation $project
- # Act
+ # Act
Install-Package $id -ProjectName $project.Name -version $oldVersion
$project.Save($project.FullName)
Build-Solution
@@ -123,7 +123,7 @@ function Test-NetCoreConsoleAppUpgradePackage {
# install and downgrade package test for .net core
function Test-NetCoreConsoleAppDowngradePackage {
-
+
# Arrange
$project = New-NetCoreConsoleApp ConsoleApp
$id = 'NuGet.Versioning'
@@ -131,7 +131,7 @@ function Test-NetCoreConsoleAppDowngradePackage {
$newVersion = '3.5.0'
Assert-NetCoreProjectCreation $project
- # Act
+ # Act
Install-Package $id -ProjectName $project.Name -version $oldVersion
$project.Save($project.FullName)
Build-Solution
@@ -147,7 +147,7 @@ function Test-NetCoreConsoleAppDowngradePackage {
# project reference test for .net core
function Test-NetCoreConsoleAppProjectReference {
-
+
# Arrange
$projectA = New-NetCoreConsoleApp ConsoleAppA
$projectB = New-NetCoreConsoleApp ConsoleAppB
@@ -155,7 +155,7 @@ function Test-NetCoreConsoleAppProjectReference {
Assert-NetCoreProjectCreation $projectA
Assert-NetCoreProjectCreation $projectB
- # Act
+ # Act
Add-ProjectReference $projectA $projectB
$projectA.Save($projectA.FullName)
@@ -172,7 +172,7 @@ function Test-NetCoreConsoleAppProjectReference {
# C -> Nuget.Versioning 3.5.0
# Assert A has reference to NuGet.Versioning
function Test-NetCoreConsoleAppTransitivePackage {
-
+
# Arrange
$projectA = New-NetCoreConsoleApp ConsoleAppA
$projectB = New-NetCoreConsoleApp ConsoleAppB
@@ -183,7 +183,7 @@ function Test-NetCoreConsoleAppTransitivePackage {
Assert-NetCoreProjectCreation $projectB
Assert-NetCoreProjectCreation $projectC
- # Act
+ # Act
Add-ProjectReference $projectB $projectC
Add-ProjectReference $projectA $projectB
Install-Package $id -ProjectName $projectC.Name -version $version
@@ -205,7 +205,7 @@ function Test-NetCoreConsoleAppTransitivePackage {
# C -> Nuget.Versioning 3.5.0
# Assert X does not have reference to NuGet.Versioning
function Test-NetCoreConsoleAppTransitivePackageLimit {
-
+
# Arrange
$projectA = New-NetCoreConsoleApp ConsoleAppA
$projectB = New-NetCoreConsoleApp ConsoleAppB
@@ -235,7 +235,7 @@ function Test-NetCoreConsoleAppTransitivePackageLimit {
Assert-NetCorePackageInLockFile $projectB $id $version
Assert-NetCorePackageInLockFile $projectA $id $version
Assert-NetCoreNoPackageReference $projectX $id
- Assert-NetCorePackageNotInLockFile $projectX $id
+ Assert-NetCorePackageNotInLockFile $projectX $id
}
# basic create for .net core template
@@ -243,7 +243,7 @@ function Test-NetCoreWebApp10Create {
# Arrange & Act
$project = New-NetCoreWebApp10 ConsoleApp
-
+
# Assert
Assert-NetCoreProjectCreation $project
}
@@ -251,14 +251,14 @@ function Test-NetCoreWebApp10Create {
# install package test for .net core
function Test-NetCoreWebApp10AppInstallPackage {
-
+
# Arrange
$project = New-NetCoreWebApp10 ConsoleApp
$id = 'NuGet.Versioning'
$version = '3.5.0'
Assert-NetCoreProjectCreation $project
- # Act
+ # Act
Install-Package $id -ProjectName $project.Name -version $version
$project.Save($project.FullName)
Build-Solution
@@ -269,14 +269,14 @@ function Test-NetCoreWebApp10AppInstallPackage {
# install and uninstall package test for .net core
function Test-NetCoreWebApp10UninstallPackage {
-
+
# Arrange
$project = New-NetCoreWebApp10 ConsoleApp
$id = 'NuGet.Versioning'
$version = '3.5.0'
Assert-NetCoreProjectCreation $project
- # Act
+ # Act
Install-Package $id -ProjectName $project.Name -version $version
$project.Save($project.FullName)
Build-Solution
@@ -313,7 +313,7 @@ function Test-NetCoreWebApp10InstallMultiplePackages {
# install and uninstall multiple packages test for .net core
function Test-NetCoreWebApp10UninstallMultiplePackage {
-
+
# Arrange
$project = New-NetCoreWebApp10 ConsoleApp
$id1 = 'NuGet.Versioning'
@@ -341,7 +341,7 @@ function Test-NetCoreWebApp10UninstallMultiplePackage {
# install and upgrade package test for .net core
function Test-NetCoreWebApp10UpgradePackage {
-
+
# Arrange
$project = New-NetCoreWebApp10 ConsoleApp
$id = 'NuGet.Versioning'
@@ -349,7 +349,7 @@ function Test-NetCoreWebApp10UpgradePackage {
$newVersion = '4.0.0-rc2'
Assert-NetCoreProjectCreation $project
- # Act
+ # Act
Install-Package $id -ProjectName $project.Name -version $oldVersion
$project.Save($project.FullName)
Build-Solution
@@ -365,7 +365,7 @@ function Test-NetCoreWebApp10UpgradePackage {
# install and downgrade package test for .net core
function Test-NetCoreWebApp10DowngradePackage {
-
+
# Arrange
$project = New-NetCoreWebApp10 ConsoleApp
$id = 'NuGet.Versioning'
@@ -373,7 +373,7 @@ function Test-NetCoreWebApp10DowngradePackage {
$newVersion = '3.5.0'
Assert-NetCoreProjectCreation $project
- # Act
+ # Act
Install-Package $id -ProjectName $project.Name -version $oldVersion
$project.Save($project.FullName)
Build-Solution
@@ -389,7 +389,7 @@ function Test-NetCoreWebApp10DowngradePackage {
# project reference test for .net core
function Test-NetCoreWebApp10ProjectReference {
-
+
# Arrange
$projectA = New-NetCoreWebApp10 ConsoleAppA
$projectB = New-NetCoreWebApp10 ConsoleAppB
@@ -397,7 +397,7 @@ function Test-NetCoreWebApp10ProjectReference {
Assert-NetCoreProjectCreation $projectA
Assert-NetCoreProjectCreation $projectB
- # Act
+ # Act
Add-ProjectReference $projectA $projectB
$projectA.Save($projectA.FullName)
@@ -415,10 +415,10 @@ function Test-NetCoreWebAppExecuteInitScriptsOnlyOnce
# Arrange
$global:PackageInitPS1Var = 0
$p = New-NetCoreWebApp10 WebApp
-
+
# Act & Assert
Install-Package PackageInitPS1 -Project $p.Name -Source $context.RepositoryPath
- Build-Solution
+ Build-Solution
Assert-True ($global:PackageInitPS1Var -eq 1)
$p | Install-Package jquery -Version 1.9
@@ -428,7 +428,7 @@ function Test-NetCoreWebAppExecuteInitScriptsOnlyOnce
# VSSolutionManager and ProjectSystemCache event test for .net core
function Test-NetCoreProjectSystemCacheUpdateEvent {
-
+
# Arrange
$projectA = New-NetCoreConsoleApp ConsoleAppA
Assert-NetCoreProjectCreation $projectA
@@ -442,10 +442,10 @@ function Test-NetCoreProjectSystemCacheUpdateEvent {
$projectA.Save($projectA.FullName)
Build-Solution
}
- Finally
+ Finally
{
[API.Test.InternalAPITestHook]::ProjectCacheEventApi_DetachHandler()
- $result = [API.Test.InternalAPITestHook]::CacheUpdateEventCount
+ $result = [API.Test.InternalAPITestHook]::CacheUpdateEventCount
}
# Assert
@@ -459,7 +459,7 @@ function Test-NetCoreProjectSystemCacheUpdateEvent {
# # C -> Nuget.Versioning 3.5.0
# # Assert A has reference to NuGet.Versioning
# function Test-NetCoreWebApp10TransitivePackage {
-
+
# # Arrange
# $projectA = New-NetCoreWebApp10 ConsoleAppA
# $projectB = New-NetCoreWebApp10 ConsoleAppB
@@ -470,7 +470,7 @@ function Test-NetCoreProjectSystemCacheUpdateEvent {
# Assert-NetCoreProjectCreation $projectB
# Assert-NetCoreProjectCreation $projectC
-# # Act
+# # Act
# Add-ProjectReference $projectB $projectC
# Add-ProjectReference $projectA $projectB
# Install-Package $id -ProjectName $projectC.Name -version $version
@@ -492,7 +492,7 @@ function Test-NetCoreProjectSystemCacheUpdateEvent {
# # C -> Nuget.Versioning 3.5.0
# # Assert X does not have reference to NuGet.Versioning
# function Test-NetCoreWebApp10TransitivePackageLimit {
-
+
# # Arrange
# $projectA = New-NetCoreWebApp10 ConsoleAppA
# $projectB = New-NetCoreWebApp10 ConsoleAppB
@@ -522,7 +522,237 @@ function Test-NetCoreProjectSystemCacheUpdateEvent {
# Assert-NetCorePackageInLockFile $projectB $id $version
# Assert-NetCorePackageInLockFile $projectA $id $version
# Assert-NetCoreNoPackageReference $projectX $id
-# Assert-NetCorePackageNotInLockFile $projectX $id
+# Assert-NetCorePackageNotInLockFile $projectX $id
# }
+function Test-NetStandardClassLibraryCreate {
+
+ # Arrange & Act
+ $project = New-NetStandardClassLibrary ClassLibrary1
+
+ # Assert
+ Assert-NetCoreProjectCreation $project
+}
+
+function Test-NetStandardClassLibraryInstallPackage {
+
+ # Arrange
+ $project = New-NetStandardClassLibrary ClassLibrary1
+ $id = 'NuGet.Versioning'
+ $version = '3.5.0'
+ Assert-NetCoreProjectCreation $project
+
+ # Act
+ Install-Package $id -ProjectName $project.Name -version $version
+ $project.Save($project.FullName)
+ Build-Solution
+
+ # Assert
+ Assert-NetCorePackageInstall $project $id $version
+}
+
+function Test-NetStandardClassLibraryUninstallPackage {
+
+ # Arrange
+ $project = New-NetStandardClassLibrary ClassLibrary1
+ $id = 'NuGet.Versioning'
+ $version = '3.5.0'
+ Assert-NetCoreProjectCreation $project
+
+ # Act
+ Install-Package $id -ProjectName $project.Name -version $version
+ $project.Save($project.FullName)
+ Build-Solution
+ Assert-NetCorePackageInstall $project $id $version
+
+ Uninstall-Package $id -ProjectName $project.Name
+ $project.Save($project.FullName)
+ Build-Solution
+
+ # Assert
+ Assert-NetCorePackageUninstall $project $id
+}
+
+function Test-NetStandardClassLibraryInstallMultiplePackages {
+
+ # Arrange
+ $project = New-NetStandardClassLibrary ClassLibrary1
+ $id1 = 'NuGet.Versioning'
+ $version1 = '3.5.0'
+ $id2 = 'NUnit'
+ $version2 = '3.6.0'
+
+ # Act
+ Install-Package $id1 -ProjectName $project.Name -version $version1
+ Install-Package $id2 -ProjectName $project.Name -version $version2
+ $project.Save($project.FullName)
+ Build-Solution
+
+ # Assert
+ Assert-NetCorePackageInstall $project $id1 $version1
+ Assert-NetCorePackageInstall $project $id2 $version2
+}
+
+function Test-NetStandardClassLibraryUninstallMultiplePackage {
+
+ # Arrange
+ $project = New-NetStandardClassLibrary ClassLibrary1
+ $id1 = 'NuGet.Versioning'
+ $version1 = '3.5.0'
+ $id2 = 'NUnit'
+ $version2 = '3.6.0'
+
+ # Act
+ Install-Package $id1 -ProjectName $project.Name -version $version1
+ Install-Package $id2 -ProjectName $project.Name -version $version2
+ $project.Save($project.FullName)
+ Build-Solution
+ Assert-NetCorePackageInstall $project $id1 $version1
+ Assert-NetCorePackageInstall $project $id2 $version2
+ Uninstall-Package $id1 -ProjectName $project.Name
+ Uninstall-Package $id2 -ProjectName $project.Name
+ $project.Save($project.FullName)
+ Build-Solution
+
+ # Assert
+ Assert-NetCorePackageUninstall $project $id1
+ Assert-NetCorePackageUninstall $project $id2
+}
+
+function Test-NetStandardClassLibraryUpgradePackage {
+
+ # Arrange
+ $project = New-NetStandardClassLibrary ClassLibrary1
+ $id = 'NuGet.Versioning'
+ $oldVersion = '3.5.0'
+ $newVersion = '4.0.0-rc2'
+ Assert-NetCoreProjectCreation $project
+
+ # Act
+ Install-Package $id -ProjectName $project.Name -version $oldVersion
+ $project.Save($project.FullName)
+ Build-Solution
+ Assert-NetCorePackageInstall $project $id $oldVersion
+
+ Update-Package $id -ProjectName $project.Name -version $newVersion
+ $project.Save($project.FullName)
+ Build-Solution
+
+ # Assert
+ Assert-NetCorePackageInstall $project $id $newVersion
+}
+
+function Test-NetStandardClassLibraryDowngradePackage {
+
+ # Arrange
+ $project = New-NetStandardClassLibrary ClassLibrary1
+ $id = 'NuGet.Versioning'
+ $oldVersion = '4.0.0-rc2'
+ $newVersion = '3.5.0'
+ Assert-NetCoreProjectCreation $project
+
+ # Act
+ Install-Package $id -ProjectName $project.Name -version $oldVersion
+ $project.Save($project.FullName)
+ Build-Solution
+ Assert-NetCorePackageInstall $project $id $oldVersion
+
+ Update-Package $id -ProjectName $project.Name -version $newVersion
+ $project.Save($project.FullName)
+ Build-Solution
+
+ # Assert
+ Assert-NetCorePackageInstall $project $id $newVersion
+}
+
+function Test-NetStandardClassLibraryProjectReference {
+
+ # Arrange
+ $projectA = New-NetStandardClassLibrary ClassLibraryA
+ $projectB = New-NetStandardClassLibrary ClassLibraryB
+
+ Assert-NetCoreProjectCreation $projectA
+ Assert-NetCoreProjectCreation $projectB
+
+ # Act
+ Add-ProjectReference $projectA $projectB
+
+ $projectA.Save($projectA.FullName)
+ $projectB.Save($projectB.FullName)
+ Build-Solution
+
+ # Assert
+ Assert-NetCoreProjectReference $projectA $projectB
+}
+
+# transitive package dependency test for .net core
+# A -> B
+# B -> C
+# C -> Nuget.Versioning 3.5.0
+# Assert A has reference to NuGet.Versioning
+function Test-NetStandardClassLibraryTransitivePackage {
+
+ # Arrange
+ $projectA = New-NetStandardClassLibrary ClassLibraryA
+ $projectB = New-NetStandardClassLibrary ClassLibraryB
+ $projectC = New-NetStandardClassLibrary ClassLibraryC
+ $id = 'NuGet.Versioning'
+ $version = '3.5.0'
+ Assert-NetCoreProjectCreation $projectA
+ Assert-NetCoreProjectCreation $projectB
+ Assert-NetCoreProjectCreation $projectC
+
+ # Act
+ Add-ProjectReference $projectB $projectC
+ Add-ProjectReference $projectA $projectB
+ Install-Package $id -ProjectName $projectC.Name -version $version
+
+ $projectA.Save($projectA.FullName)
+ $projectB.Save($projectB.FullName)
+ $projectC.Save($projectC.FullName)
+ Build-Solution
+ # Assert
+ Assert-NetCorePackageInstall $projectC $id $version
+ Assert-NetCorePackageInLockFile $projectB $id $version
+ Assert-NetCorePackageInLockFile $projectA $id $version
+}
+
+# transitive package dependency limit test for .net core
+# A -> X, B
+# B -> C
+# C -> Nuget.Versioning 3.5.0
+# Assert X does not have reference to NuGet.Versioning
+function Test-NetStandardClassLibraryTransitivePackageLimit {
+
+ # Arrange
+ $projectA = New-NetStandardClassLibrary ClassLibraryA
+ $projectB = New-NetStandardClassLibrary ClassLibraryB
+ $projectC = New-NetStandardClassLibrary ClassLibraryC
+ $projectX = New-NetStandardClassLibrary ClassLibraryX
+ $id = 'NuGet.Versioning'
+ $version = '3.5.0'
+ Assert-NetCoreProjectCreation $projectA
+ Assert-NetCoreProjectCreation $projectB
+ Assert-NetCoreProjectCreation $projectC
+ Assert-NetCoreProjectCreation $projectX
+
+ # Act
+ Add-ProjectReference $projectA $projectX
+ Add-ProjectReference $projectA $projectB
+ Add-ProjectReference $projectB $projectC
+ Install-Package $id -ProjectName $projectC.Name -version $version
+
+ $projectA.Save($projectA.FullName)
+ $projectB.Save($projectB.FullName)
+ $projectC.Save($projectC.FullName)
+ $projectX.Save($projectX.FullName)
+ Build-Solution
+
+ # Assert
+ Assert-NetCorePackageInstall $projectC $id $version
+ Assert-NetCorePackageInLockFile $projectB $id $version
+ Assert-NetCorePackageInLockFile $projectA $id $version
+ Assert-NetCoreNoPackageReference $projectX $id
+ Assert-NetCorePackageNotInLockFile $projectX $id
+}
diff --git a/test/EndToEnd/vs.ps1 b/test/EndToEnd/vs.ps1
index d0cfabbde64..82d911a134b 100644
--- a/test/EndToEnd/vs.ps1
+++ b/test/EndToEnd/vs.ps1
@@ -19,7 +19,7 @@ function New-BuildIntegratedProj
[string]$ProjectName,
[string]$SolutionFolder
)
-
+
if ((Get-VSVersion) -ge '14.0')
{
New-Project BuildIntegratedProj $ProjectName $SolutionFolder
@@ -35,7 +35,7 @@ function Wait-OnNetCoreRestoreCompletion{
[parameter(Mandatory = $true)]
$Project
)
-
+
$NetCoreLockFilePath = Get-NetCoreLockFilePath $Project
$timeout = New-Timespan -Minutes 2
$sw = [Diagnostics.Stopwatch]::StartNew()
@@ -53,7 +53,7 @@ function New-NetCoreConsoleApp
[string]$ProjectName,
[string]$SolutionFolder
)
-
+
if ((Get-VSVersion) -ge '15.0')
{
$project = New-Project NetCoreConsoleApp $ProjectName $SolutionFolder
@@ -72,7 +72,7 @@ function New-NetCoreWebApp10
[string]$ProjectName,
[string]$SolutionFolder
)
-
+
if ((Get-VSVersion) -ge '15.0')
{
$project = New-Project NetCoreWebApplication1.0 $ProjectName $SolutionFolder
@@ -85,7 +85,26 @@ function New-NetCoreWebApp10
}
}
-function New-CpsApp
+function New-NetStandardClassLibrary
+{
+ param(
+ [string]$ProjectName,
+ [string]$SolutionFolder
+ )
+
+ if ((Get-VSVersion) -ge '15.0')
+ {
+ $project = New-Project NetStandardClassLibrary $ProjectName $SolutionFolder
+ Wait-OnNetCoreRestoreCompletion $project
+ return $project
+ }
+ else
+ {
+ throw "SKIP: $($_)"
+ }
+}
+
+function New-CpsApp
{
param(
[string]$ProjectName,
@@ -115,14 +134,14 @@ function Get-SolutionFullName {
return [API.Test.VSSolutionHelper]::GetSolutionFullName()
}
-function Close-Solution
+function Close-Solution
{
Write-Verbose "Close-Solution function"
[API.Test.VSSolutionHelper]::CloseSolution()
}
-function Open-Solution
+function Open-Solution
{
param
(
@@ -131,7 +150,7 @@ function Open-Solution
$Path
)
Write-Verbose "Open-Solution function"
-
+
[API.Test.VSSolutionHelper]::OpenSolution($Path)
}
@@ -144,7 +163,7 @@ function SaveAs-Solution
$Path
)
Write-Verbose "SaveAs-Solution function"
-
+
[API.Test.VSSolutionHelper]::SaveAsSolution($Path)
}
@@ -214,7 +233,7 @@ function Rename-SolutionFolder {
}
function New-ClassLibrary {
- param(
+ param(
[string]$ProjectName,
[string]$SolutionFolderName
)
@@ -222,7 +241,7 @@ function New-ClassLibrary {
New-Project ClassLibrary $ProjectName $SolutionFolderName
}
-function New-LightSwitchApplication
+function New-LightSwitchApplication
{
param(
[string]$ProjectName,
@@ -232,7 +251,7 @@ function New-LightSwitchApplication
New-Project JScriptVisualBasicLightSwitchProjectTemplate $ProjectName $SolutionFolder
}
-function New-PortableLibrary
+function New-PortableLibrary
{
param(
[string]$ProjectName,
@@ -246,11 +265,11 @@ function New-PortableLibrary
}
catch {
# If we're unable to create the project that means we probably don't have some SDK installed
- # Signal to the runner that we want to skip this test
+ # Signal to the runner that we want to skip this test
throw "SKIP: $($_)"
}
- if ($Profile)
+ if ($Profile)
{
$name = $project.Name
$project.Properties.Item("TargetFrameworkMoniker").Value = ".NETPortable,Version=v4.0,Profile=$Profile"
@@ -260,14 +279,14 @@ function New-PortableLibrary
$project
}
-function New-JavaScriptApplication
+function New-JavaScriptApplication
{
param(
[string]$ProjectName,
[string]$SolutionFolder
)
- try
+ try
{
if ((Get-VSVersion) -eq '12.0')
{
@@ -277,44 +296,44 @@ function New-JavaScriptApplication
{
New-Project WinJS_Dev14 $ProjectName $SolutionFolder
}
- else
+ else
{
New-Project WinJS $ProjectName $SolutionFolder
}
}
catch {
# If we're unable to create the project that means we probably don't have some SDK installed
- # Signal to the runner that we want to skip this test
+ # Signal to the runner that we want to skip this test
throw "SKIP: $($_)"
}
}
-function New-JavaScriptApplication81
+function New-JavaScriptApplication81
{
param(
[string]$ProjectName,
[string]$SolutionFolder
)
- try
+ try
{
New-Project WinJSBlue $ProjectName $SolutionFolder
}
catch {
# If we're unable to create the project that means we probably don't have some SDK installed
- # Signal to the runner that we want to skip this test
+ # Signal to the runner that we want to skip this test
throw "SKIP: $($_)"
}
}
-function New-JavaScriptWindowsPhoneApp81
+function New-JavaScriptWindowsPhoneApp81
{
param(
[string]$ProjectName,
[string]$SolutionFolder
)
- try
+ try
{
New-Project WindowsPhoneApp81JS $ProjectName $SolutionFolder
}
@@ -342,20 +361,20 @@ function New-NativeWinStoreApplication
{
New-Project CppWinStoreApplication_Dev14 $ProjectName $SolutionFolder
}
- else
+ else
{
New-Project CppWinStoreApplication $ProjectName $SolutionFolder
}
}
catch {
# If we're unable to create the project that means we probably don't have some SDK installed
- # Signal to the runner that we want to skip this test
+ # Signal to the runner that we want to skip this test
throw "SKIP: $($_)"
}
}
function New-ConsoleApplication {
- param(
+ param(
[string]$ProjectName,
[string]$SolutionFolder
)
@@ -364,7 +383,7 @@ function New-ConsoleApplication {
}
function New-WebApplication {
- param(
+ param(
[string]$ProjectName,
[string]$SolutionFolder
)
@@ -373,7 +392,7 @@ function New-WebApplication {
}
function New-VBConsoleApplication {
- param(
+ param(
[string]$ProjectName,
[string]$SolutionFolder
)
@@ -381,8 +400,8 @@ function New-VBConsoleApplication {
New-Project VBConsoleApplication $ProjectName $SolutionFolder
}
-function New-MvcApplication {
- param(
+function New-MvcApplication {
+ param(
[string]$ProjectName,
[string]$SolutionFolder
)
@@ -390,8 +409,8 @@ function New-MvcApplication {
New-Project EmptyMvcWebApplicationProjectTemplatev4.0.csaspx $ProjectName $SolutionFolder
}
-function New-MvcWebSite {
- param(
+function New-MvcWebSite {
+ param(
[string]$ProjectName,
[string]$SolutionFolder
)
@@ -400,7 +419,7 @@ function New-MvcWebSite {
}
function New-WebSite {
- param(
+ param(
[string]$ProjectName,
[string]$SolutionFolder
)
@@ -409,7 +428,7 @@ function New-WebSite {
}
function New-FSharpLibrary {
- param(
+ param(
[string]$ProjectName,
[string]$SolutionFolder
)
@@ -418,7 +437,7 @@ function New-FSharpLibrary {
}
function New-FSharpConsoleApplication {
- param(
+ param(
[string]$ProjectName,
[string]$SolutionFolder
)
@@ -427,7 +446,7 @@ function New-FSharpConsoleApplication {
}
function New-WPFApplication {
- param(
+ param(
[string]$ProjectName,
[string]$SolutionFolder
)
@@ -436,7 +455,7 @@ function New-WPFApplication {
}
function New-SilverlightClassLibrary {
- param(
+ param(
[string]$ProjectName,
[string]$SolutionFolder
)
@@ -453,7 +472,7 @@ function New-SilverlightClassLibrary {
}
function New-SilverlightApplication {
- param(
+ param(
[string]$ProjectName,
[string]$SolutionFolder
)
@@ -470,7 +489,7 @@ function New-SilverlightApplication {
}
function New-WindowsPhoneClassLibrary {
- param(
+ param(
[string]$ProjectName,
[string]$SolutionFolder
)
@@ -485,7 +504,7 @@ function New-WindowsPhoneClassLibrary {
}
catch {
# If we're unable to create the project that means we probably don't have some SDK installed
- # Signal to the runner that we want to skip this test
+ # Signal to the runner that we want to skip this test
throw "SKIP: $($_)"
}
}
@@ -497,13 +516,13 @@ function New-DNXClassLibrary
[string]$SolutionFolder
)
- try
+ try
{
New-Project DNXClassLibrary $ProjectName $SolutionFolder
}
catch {
# If we're unable to create the project that means we probably don't have some SDK installed
- # Signal to the runner that we want to skip this test
+ # Signal to the runner that we want to skip this test
throw "SKIP: $($_)"
}
}
@@ -515,13 +534,13 @@ function New-DNXConsoleApp
[string]$SolutionFolder
)
- try
+ try
{
New-Project DNXConsoleApp $ProjectName $SolutionFolder
}
catch {
# If we're unable to create the project that means we probably don't have some SDK installed
- # Signal to the runner that we want to skip this test
+ # Signal to the runner that we want to skip this test
throw "SKIP: $($_)"
}
}
@@ -550,11 +569,11 @@ function Get-AssemblyReference {
$Project,
[parameter(Mandatory = $true)]
[string]$Reference
- )
+ )
try {
return $Project.Object.References.Item($Reference)
}
- catch {
+ catch {
}
return $null
}
@@ -565,14 +584,14 @@ function Get-PropertyValue {
$Project,
[parameter(Mandatory = $true)]
[string]$PropertyName
- )
+ )
try {
- $property = $Project.Properties.Item($PropertyName)
+ $property = $Project.Properties.Item($PropertyName)
if($property) {
return $property.Value
}
}
- catch {
+ catch {
}
return $null
}
@@ -583,7 +602,7 @@ function Get-MsBuildPropertyValue {
$Project,
[parameter(Mandatory = $true)]
[string]$PropertyName
- )
+ )
$msBuildProject = Get-MsBuildProject $project
return $msBuildProject.GetPropertyValue($PropertyName)
@@ -591,7 +610,7 @@ function Get-MsBuildPropertyValue {
return $null
}
-function Get-MsBuildProject
+function Get-MsBuildProject
{
param(
[parameter(Mandatory = $true)]
@@ -618,7 +637,7 @@ function Get-ProjectDir {
# c++ project has ProjectDirectory
$path = Get-PropertyValue $Project 'ProjectDirectory'
- if ($path)
+ if ($path)
{
return $path
}
@@ -635,24 +654,24 @@ function Get-ProjectDir {
$path
}
-function Get-ProjectName
+function Get-ProjectName
{
param(
[parameter(Mandatory = $true)]
$Project
)
-
+
$projectName = $Project.Name
- if ($project.Type -eq 'Web Site' -and $project.Properties.Item("WebSiteType").Value -eq "0")
+ if ($project.Type -eq 'Web Site' -and $project.Properties.Item("WebSiteType").Value -eq "0")
{
- # If this is a WebSite project and WebSiteType = 0, meaning it's configured to use Casini as opposed to IIS Express,
+ # If this is a WebSite project and WebSiteType = 0, meaning it's configured to use Casini as opposed to IIS Express,
# then $Project.Name will return the full path to the website directory. We don't want to use the full path, thus
# we extract the directory name out of it.
$projectName = Split-Path -Leaf $projectName
}
-
+
$projectName
}
@@ -661,7 +680,7 @@ function Get-OutputPath {
[parameter(Mandatory = $true)]
$Project
)
-
+
$outputPath = $Project.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value
Join-Path (Get-ProjectDir) $outputPath
}
@@ -688,7 +707,7 @@ function Get-ProjectItemPath {
[string]$Path
)
$item = Get-ProjectItem $Project $Path
-
+
if($item) {
return $item.Properties.Item("FullPath").Value
}
@@ -718,12 +737,12 @@ function Get-ProjectItem {
Process {
$pathParts = $Path.Split('\')
$projectItems = $Project.ProjectItems
-
+
foreach($part in $pathParts) {
if(!$part -or $part -eq '') {
continue
}
-
+
try {
$subItem = $projectItems.Item($part)
}
@@ -737,7 +756,7 @@ function Get-ProjectItem {
if($subItem.Kind -eq $FileKind) {
return $subItem
}
-
+
# Force array
return ,$projectItems
}
@@ -775,11 +794,11 @@ function Enable-PackageRestore {
}
$componentService = Get-VSComponentModel
-
+
# change active package source to "All"
$packageSourceProvider = $componentService.GetService([NuGet.VisualStudio.IVsPackageSourceProvider])
$packageSourceProvider.ActivePackageSource = [NuGet.VisualStudio.AggregatePackageSource]::Instance
-
+
$packageRestoreManager = $componentService.GetService([NuGet.VisualStudio.IPackageRestoreManager])
$packageRestoreManager.EnableCurrentSolutionForRestore($false)
}
@@ -796,6 +815,6 @@ function Check-NuGetConfig {
}
}
-function Get-BuildOutput {
+function Get-BuildOutput {
return [API.Test.VSHelper]::GetBuildOutput()
}
\ No newline at end of file