diff --git a/Microsoft.DotNet.Cli.sln b/Microsoft.DotNet.Cli.sln
index f1fed5401..26d5ac266 100644
--- a/Microsoft.DotNet.Cli.sln
+++ b/Microsoft.DotNet.Cli.sln
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
-VisualStudioVersion = 15.0.26419.0
+VisualStudioVersion = 15.0.26510.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED2FE3E2-F7E7-4389-8231-B65123F2076F}"
EndProject
@@ -30,7 +30,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{89905EC4
build\BuildDefaults.props = build\BuildDefaults.props
build\BuildInfo.targets = build\BuildInfo.targets
build\BundledRuntimes.props = build\BundledRuntimes.props
- build\BundledSdks.proj = build\BundledSdks.proj
build\BundledSdks.props = build\BundledSdks.props
build\BundledTemplates.proj = build\BundledTemplates.proj
build\BundledTemplates.props = build\BundledTemplates.props
@@ -48,10 +47,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{89905EC4
build\InstallerInfo.props = build\InstallerInfo.props
build\Microsoft.DotNet.Cli.tasks = build\Microsoft.DotNet.Cli.tasks
build\MSBuildExtensions.props = build\MSBuildExtensions.props
+ build\MSBuildExtensions.targets = build\MSBuildExtensions.targets
build\OutputDirectories.props = build\OutputDirectories.props
build\Package.targets = build\Package.targets
build\Prepare.targets = build\Prepare.targets
build\Publish.targets = build\Publish.targets
+ build\RestoreDependency.proj = build\RestoreDependency.proj
build\sdks\sdks.csproj = build\sdks\sdks.csproj
build\Signing.proj = build\Signing.proj
build\Stage0.props = build\Stage0.props
diff --git a/TestAssets/DesktopTestProjects/NETFrameworkReferenceNETStandard20/TestApp/Program.cs b/TestAssets/DesktopTestProjects/NETFrameworkReferenceNETStandard20/TestApp/Program.cs
new file mode 100644
index 000000000..a168da37c
--- /dev/null
+++ b/TestAssets/DesktopTestProjects/NETFrameworkReferenceNETStandard20/TestApp/Program.cs
@@ -0,0 +1,15 @@
+// Copyright (c) .NET Foundation and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+
+namespace TestApp
+{
+ class Program
+ {
+ public static void Main(string[] args)
+ {
+ Console.WriteLine(TestLibrary.Helper.GetMessage());
+ }
+ }
+}
diff --git a/TestAssets/DesktopTestProjects/NETFrameworkReferenceNETStandard20/TestApp/TestApp.csproj b/TestAssets/DesktopTestProjects/NETFrameworkReferenceNETStandard20/TestApp/TestApp.csproj
new file mode 100644
index 000000000..4f3707aba
--- /dev/null
+++ b/TestAssets/DesktopTestProjects/NETFrameworkReferenceNETStandard20/TestApp/TestApp.csproj
@@ -0,0 +1,12 @@
+
+
+
+ Exe
+ net461
+
+
+
+
+
+
+
diff --git a/TestAssets/DesktopTestProjects/NETFrameworkReferenceNETStandard20/TestLibrary/Helper.cs b/TestAssets/DesktopTestProjects/NETFrameworkReferenceNETStandard20/TestLibrary/Helper.cs
new file mode 100644
index 000000000..67b32cfdb
--- /dev/null
+++ b/TestAssets/DesktopTestProjects/NETFrameworkReferenceNETStandard20/TestLibrary/Helper.cs
@@ -0,0 +1,24 @@
+// Copyright (c) .NET Foundation and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+
+namespace TestLibrary
+{
+ public static class Helper
+ {
+ ///
+ /// Gets the message from the helper. This comment is here to help test XML documentation file generation, please do not remove it.
+ ///
+ /// A message
+ public static string GetMessage()
+ {
+ return "This string came from the test library!";
+ }
+
+ public static void SayHi()
+ {
+ Console.WriteLine("Hello there!");
+ }
+ }
+}
\ No newline at end of file
diff --git a/TestAssets/DesktopTestProjects/NETFrameworkReferenceNETStandard20/TestLibrary/TestLibrary.csproj b/TestAssets/DesktopTestProjects/NETFrameworkReferenceNETStandard20/TestLibrary/TestLibrary.csproj
new file mode 100644
index 000000000..9f5c4f4ab
--- /dev/null
+++ b/TestAssets/DesktopTestProjects/NETFrameworkReferenceNETStandard20/TestLibrary/TestLibrary.csproj
@@ -0,0 +1,7 @@
+
+
+
+ netstandard2.0
+
+
+
diff --git a/build.proj b/build.proj
index ac36138fb..bac606d59 100644
--- a/build.proj
+++ b/build.proj
@@ -20,7 +20,7 @@
DependsOnTargets="MSBuildWorkaroundTarget;
RestoreDotnetCliBuildFramework">
-
diff --git a/build/BackwardsCompatibilityRuntimes.props b/build/BackwardsCompatibilityRuntimes.props
index 72eddd70d..e63013084 100644
--- a/build/BackwardsCompatibilityRuntimes.props
+++ b/build/BackwardsCompatibilityRuntimes.props
@@ -5,16 +5,16 @@
1.1.0
1.1.0
- dotnet-host-$(ProductMonikerRid).$(BackwardsCompatibility110SharedHostVersion)$(InstallerExtension)
- $(PackagesDirectory)/$(BackwardsCompatibility110DownloadedSharedHostInstallerFileName)
+ dotnet-host-$(HostMonikerRid).$(BackwardsCompatibility110SharedHostVersion)$(InstallerExtension)
+ $(PackagesDirectory)/$(BackwardsCompatibility110DownloadedSharedHostInstallerFileName)
- dotnet-hostfxr-$(ProductMonikerRid).$(BackwardsCompatibility110HostFxrVersion)$(InstallerExtension)
- $(PackagesDirectory)/$(BackwardsCompatibility110DownloadedHostFxrInstallerFileName)
+ dotnet-hostfxr-$(HostMonikerRid).$(BackwardsCompatibility110HostFxrVersion)$(InstallerExtension)
+ $(PackagesDirectory)/$(BackwardsCompatibility110DownloadedHostFxrInstallerFileName)
- dotnet-sharedframework-$(ProductMonikerRid).$(BackwardsCompatibility110SharedFrameworkVersion)$(InstallerExtension)
- $(PackagesDirectory)/$(BackwardsCompatibility110DownloadedSharedFrameworkInstallerFileName)
+ dotnet-sharedframework-$(HostMonikerRid).$(BackwardsCompatibility110SharedFrameworkVersion)$(InstallerExtension)
+ $(PackagesDirectory)/$(BackwardsCompatibility110DownloadedSharedFrameworkInstallerFileName)
- dotnet-$(ProductMonikerRid).$(BackwardsCompatibility110SharedFrameworkVersion)$(ArchiveExtension)
+ dotnet-$(HostMonikerRid).$(BackwardsCompatibility110SharedFrameworkVersion)$(ArchiveExtension)
$(CoreSetupBlobRootUrl)$(BackwardsCompatibility110CoreSetupChannel)
$(BackwardsCompatibility110CoreSetupBlobRootUrlWithChannel)/Binaries/$(BackwardsCompatibility110SharedFrameworkVersion)
@@ -34,24 +34,24 @@
<_DownloadAndExtractItem Include="BackwardsCompatibility110DownloadedSharedFrameworkInstallerFile"
- Condition="!Exists('$(BackwardsCompatibility110DownloadedSharedFrameworkInstallerFile)') And '$(InstallerExtension)' != ''">
+ Condition="!Exists('$(BackwardsCompatibility110DownloadedSharedFrameworkInstallerFile)') And '$(OSName)' != 'linux'">
$(BackwardsCompatibility110CoreSetupInstallerBlobRootUrl)/$(BackwardsCompatibility110SharedFrameworkVersion)/$(BackwardsCompatibility110DownloadedSharedFrameworkInstallerFileName)
$(BackwardsCompatibility110DownloadedSharedFrameworkInstallerFile)
<_DownloadAndExtractItem Include="BackwardsCompatibility110DownloadedSharedHostInstallerFile"
- Condition="!Exists('$(BackwardsCompatibility110DownloadedSharedHostInstallerFile)') And '$(InstallerExtension)' != ''">
+ Condition="!Exists('$(BackwardsCompatibility110DownloadedSharedHostInstallerFile)') And '$(OSName)' != 'linux'">
$(BackwardsCompatibility110CoreSetupInstallerBlobRootUrl)/$(BackwardsCompatibility110SharedHostVersion)/$(BackwardsCompatibility110DownloadedSharedHostInstallerFileName)
$(BackwardsCompatibility110DownloadedSharedHostInstallerFile)
<_DownloadAndExtractItem Include="BackwardsCompatibility110DownloadedHostFxrInstallerFile"
- Condition="!Exists('$(BackwardsCompatibility110DownloadedHostFxrInstallerFile)') And '$(InstallerExtension)' != ''">
+ Condition="!Exists('$(BackwardsCompatibility110DownloadedHostFxrInstallerFile)') And '$(OSName)' != 'linux'">
$(BackwardsCompatibility110CoreSetupInstallerBlobRootUrl)/$(BackwardsCompatibility110HostFxrVersion)/$(BackwardsCompatibility110DownloadedHostFxrInstallerFileName)
$(BackwardsCompatibility110DownloadedHostFxrInstallerFile)
-
\ No newline at end of file
+
diff --git a/build/Branding.props b/build/Branding.props
index 96068e439..07cf66d29 100644
--- a/build/Branding.props
+++ b/build/Branding.props
@@ -13,14 +13,21 @@
'$(Rid)' == 'fedora.24-x64' OR
'$(Rid)' == 'opensuse.42.1-x64' ">$(Rid)
$(OSName)-$(Architecture)
+ $(HostRid)
+ $(HostOSName)-$(Architecture)
dotnet-sdk-internal
dotnet-sdk-debug
dotnet-sdk
$(ArtifactNameSdk)-$(SdkVersion)-$(ProductMonikerRid)
+
+
$(ArtifactNameSdkDebug)-$(SdkVersion)-$(ProductMonikerRid)
$(ArtifactNameCombinedHostHostFxrFrameworkSdk)-$(SdkVersion)-$(ProductMonikerRid)
-
+ $(ArtifactNameCombinedHostHostFxrFrameworkSdk)-$(SdkVersion)-$(HostMonikerRid)
diff --git a/build/BuildInfo.targets b/build/BuildInfo.targets
index 751f10737..df28e1980 100644
--- a/build/BuildInfo.targets
+++ b/build/BuildInfo.targets
@@ -9,10 +9,16 @@
- $(HostRid)
- x64
- $(HostOSName)
- $(HostOSPlatform)
+ True
+ $(HostRid)
+ x64
+ $(HostOSName)
+ $(HostOSPlatform)
+
+ linux-x64
+ x64
+ linux
+ linux
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
diff --git a/build/BundledRuntimes.props b/build/BundledRuntimes.props
index 4484c7dc8..2d79fa46f 100644
--- a/build/BundledRuntimes.props
+++ b/build/BundledRuntimes.props
@@ -1,10 +1,10 @@
- $(Rid)
- $(ProductMonikerRid)
+ $(HostRid)
+ $(HostMonikerRid)
- -internal
+ -internal
dotnet-host$(InstallerStartSuffix)-$(SharedHostVersion)-$(CoreSetupRid)$(InstallerExtension)
@@ -34,8 +34,8 @@
$(CoreSetupBlobRootUrl)aspnetcore/store/$(AspNetCoreRuntimeVersion)
- $(OSName)$(Architecture)
- $(OSName)
+ $(HostOSName)$(Architecture)
+ $(HostOSName)
linux
-$(AspNetCoreCoherenceTimestamp)
@@ -43,7 +43,7 @@
Build.RS.$(AspNetCoreRuntimeInstallerArchiveFileNameOSToken)$(AspNetCoreRuntimeInstallerArchiveSuffix)$(ArchiveExtension)
$(PackagesDirectory)/$(AspNetCoreRuntimeInstallerArchiveFileName)
- AspNetCorePackageStoreLib$(Architecture)$(AspNetCoreRuntimeStoreSuffix).wixlib
+ AspNetCorePackageStoreLib$(Architecture)$(AspNetCoreRuntimeStoreSuffix).wixlib
$(PackagesDirectory)/$(AspNetCoreRuntimeInstallerWixLibFileName)
diff --git a/build/BundledSdks.proj b/build/BundledSdks.proj
deleted file mode 100644
index 4408ca0a4..000000000
--- a/build/BundledSdks.proj
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
- $([MSBuild]::Unescape($(CLIBuildDll)))
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(NuGetPackagesDir)/$(SdkPackageName.ToLower())/$(SdkPackageVersion.ToLower())
-
-
-
diff --git a/build/DependencyVersions.props b/build/DependencyVersions.props
index 5a5185457..2f506bbcf 100644
--- a/build/DependencyVersions.props
+++ b/build/DependencyVersions.props
@@ -6,29 +6,31 @@
2.3.0-beta2-61716-09
1.6.0-beta2-25304
4.2.0-rc-170602-0
- 2.0.0-preview2-20170602-1
+ 2.0.0-preview2-20170608-2
4.3.0-preview3-4146
+ 2.0.0-preview2-20170608-2
+ 2.0.0-preview2-25331-02
2.0.0-rel-20170518-512
- 15.3.0-preview-20170601-03
+ 15.3.0-preview-20170609-02
$(CLI_SharedFrameworkVersion)
$(CLI_SharedFrameworkVersion)
$(CLI_SharedFrameworkVersion)
- 1.0.0-beta2-20170606-253
- 1.0.0-beta2-20170606-253
- 1.0.0-beta2-20170606-253
+ 1.0.0-beta2-20170608-254
+ 1.0.0-beta2-20170608-256
+ 1.0.0-beta2-20170608-256
2.0.0-preview2-25407-01
2.0.0-preview2-25407-01
0.1.0-alpha-142
1.2.1-alpha-002133
0.2.0
- 1.0.0-preview-000249
+ 1.0.0-preview-000286
0.2.0-beta-000042
timestamped
- 2.0.0-preview2-158
+ 2.0.0-preview2-168
preview2
- 25487
+ 25571
diff --git a/build/FileExtensions.props b/build/FileExtensions.props
index cc9f7e79c..a6c6fca35 100644
--- a/build/FileExtensions.props
+++ b/build/FileExtensions.props
@@ -1,23 +1,23 @@
- .zip
- .tar.gz
+ .zip
+ .tar.gz
- .msi
- .pkg
- .deb
+ .msi
+ .pkg
+ .deb
- .exe
- $(InstallerExtension)
- $(InstallerExtension)
+ .exe
+ $(InstallerExtension)
+ $(InstallerExtension)
lib
-
+
.so
- .dll
- .dylib
+ .dll
+ .dylib
.exe
diff --git a/build/MSBuildExtensions.targets b/build/MSBuildExtensions.targets
index b8d2d97e9..ed4d4addc 100644
--- a/build/MSBuildExtensions.targets
+++ b/build/MSBuildExtensions.targets
@@ -1,12 +1,64 @@
+ DependsOnTargets="GenerateBundledVersionsProps;RestoreMSBuildExtensionsPackages">
+
+
+
+
+
+
+
+
+
+ Microsoft.NET.Build.Extensions
+ 15.0
+ $(NuGetPackagesDir)/$(MSBuildExtensionsPackageName.ToLower())/$(CLI_MSBuildExtensions_Version.ToLower())
+
+ NETStandard.Library.NETFramework
+ $(NuGetPackagesDir)/$(NETStandardLibraryNETFrameworkPackageName.ToLower())/$(CLI_NETStandardLibraryNETFrameworkVersion.ToLower())
+
+
+
+
+
+
+
+
+
+
+ CLIBuildDll=$(CLIBuildDll);
+ NuGetPackagesDir=$(NuGetPackagesDir);
+ DependencyPackageName=%(ExtensionPackageToRestore.Identity);
+ DependencyPackageVersion=%(ExtensionPackageToRestore.Version);
+ Stage0Directory=$(Stage0Directory)
+
+
+
+
+
+
+
+
Microsoft.NETCoreSdk.BundledVersions.props
diff --git a/build/RestoreDependency.proj b/build/RestoreDependency.proj
new file mode 100644
index 000000000..142f5e929
--- /dev/null
+++ b/build/RestoreDependency.proj
@@ -0,0 +1,46 @@
+
+
+
+
+ $([MSBuild]::Unescape($(CLIBuildDll)))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(NuGetPackagesDir)/$(DependencyPackageName.ToLower())/$(DependencyPackageVersion.ToLower())
+
+
+
diff --git a/build/package/Installer.DEB.proj b/build/package/Installer.DEB.proj
index 9310623cc..32721227c 100644
--- a/build/package/Installer.DEB.proj
+++ b/build/package/Installer.DEB.proj
@@ -10,11 +10,11 @@
TestDebuild;
BuildSdkDeb;
TestSdkDeb;"
- Condition=" '$(OSName)' == 'ubuntu' OR '$(OSName)' == 'debian' "
+ Condition=" '$(HostOSName)' == 'ubuntu' OR '$(HostOSName)' == 'debian' "
Outputs="@(GeneratedInstallers)"/>
+
diff --git a/build/sdks/sdks.csproj b/build/sdks/sdks.csproj
index 4c8158628..b7c9941c0 100755
--- a/build/sdks/sdks.csproj
+++ b/build/sdks/sdks.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/build_projects/dotnet-cli-build/ReplaceFileContents.cs b/build_projects/dotnet-cli-build/ReplaceFileContents.cs
index 504175559..b0baf4179 100644
--- a/build_projects/dotnet-cli-build/ReplaceFileContents.cs
+++ b/build_projects/dotnet-cli-build/ReplaceFileContents.cs
@@ -3,6 +3,7 @@
using System;
using System.IO;
+using System.Text.RegularExpressions;
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;
@@ -84,7 +85,8 @@ namespace Microsoft.DotNet.Cli.Build
var replacementPattern = ReplacementPatterns[i].ItemSpec;
var replacementString = ReplacementStrings[i].ItemSpec;
- outText = outText.Replace(replacementPattern, replacementString);
+ var regex = new Regex(replacementPattern);
+ outText = regex.Replace(outText, replacementString);
}
return outText;
diff --git a/run-build.ps1 b/run-build.ps1
index e37226c4e..d3bb1152b 100644
--- a/run-build.ps1
+++ b/run-build.ps1
@@ -80,8 +80,8 @@ $env:VSTEST_TRACE_BUILD=1
# install a stage0
$dotnetInstallPath = Join-Path $RepoRoot "scripts\obtain\dotnet-install.ps1"
-Write-Output "$dotnetInstallPath -Channel ""release/2.0.0"" -InstallDir $env:DOTNET_INSTALL_DIR -Architecture ""$Architecture"" -Version 2.0.0-preview2-006349"
-Invoke-Expression "$dotnetInstallPath -Channel ""release/2.0.0"" -InstallDir $env:DOTNET_INSTALL_DIR -Architecture ""$Architecture"" -Version 2.0.0-preview2-006349"
+Write-Output "$dotnetInstallPath -Channel ""release/2.0.0"" -InstallDir $env:DOTNET_INSTALL_DIR -Architecture ""$Architecture"""
+Invoke-Expression "$dotnetInstallPath -Channel ""release/2.0.0"" -InstallDir $env:DOTNET_INSTALL_DIR -Architecture ""$Architecture"""
if ($LastExitCode -ne 0)
{
Write-Output "The .NET CLI installation failed with exit code $LastExitCode"
diff --git a/run-build.sh b/run-build.sh
index 2bb5b7b69..31497fb16 100755
--- a/run-build.sh
+++ b/run-build.sh
@@ -155,7 +155,7 @@ export VSTEST_TRACE_BUILD=1
DOTNET_MULTILEVEL_LOOKUP=0
# Install a stage 0
-(set -x ; "$REPOROOT/scripts/obtain/dotnet-install.sh" --channel "release/2.0.0" --version "2.0.0-preview2-006349" --install-dir "$DOTNET_INSTALL_DIR" --architecture "$ARCHITECTURE" $LINUX_PORTABLE_INSTALL_ARGS)
+(set -x ; "$REPOROOT/scripts/obtain/dotnet-install.sh" --channel "release/2.0.0" --install-dir "$DOTNET_INSTALL_DIR" --architecture "$ARCHITECTURE" $LINUX_PORTABLE_INSTALL_ARGS)
EXIT_CODE=$?
if [ $EXIT_CODE != 0 ]; then
diff --git a/scripts/obtain/dotnet-install.ps1 b/scripts/obtain/dotnet-install.ps1
index c7bd09a56..f4869d690 100644
--- a/scripts/obtain/dotnet-install.ps1
+++ b/scripts/obtain/dotnet-install.ps1
@@ -253,7 +253,7 @@ function Get-Download-Link([string]$AzureFeed, [string]$Channel, [string]$Specif
$PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/dotnet-runtime-$SpecificVersion-win-$CLIArchitecture.zip"
}
else {
- $PayloadURL = "$AzureFeed/Sdk/$SpecificVersion/dotnet-dev-$SpecificVersion-win-$CLIArchitecture.zip"
+ $PayloadURL = "$AzureFeed/Sdk/$SpecificVersion/dotnet-sdk-$SpecificVersion-win-$CLIArchitecture.zip"
}
Say-Verbose "Constructed primary payload URL: $PayloadURL"
diff --git a/scripts/obtain/dotnet-install.sh b/scripts/obtain/dotnet-install.sh
index 83ad96d17..c4d0c5850 100755
--- a/scripts/obtain/dotnet-install.sh
+++ b/scripts/obtain/dotnet-install.sh
@@ -400,7 +400,7 @@ construct_download_link() {
if [ "$shared_runtime" = true ]; then
download_link="$azure_feed/Runtime/$specific_version/dotnet-runtime-$specific_version-$osname-$normalized_architecture.tar.gz"
else
- download_link="$azure_feed/Sdk/$specific_version/dotnet-dev-$specific_version-$osname-$normalized_architecture.tar.gz"
+ download_link="$azure_feed/Sdk/$specific_version/dotnet-sdk-$specific_version-$osname-$normalized_architecture.tar.gz"
fi
echo "$download_link"
diff --git a/src/dotnet/CommonLocalizableStrings.resx b/src/dotnet/CommonLocalizableStrings.resx
index 708b0daf3..a2f5c3270 100644
--- a/src/dotnet/CommonLocalizableStrings.resx
+++ b/src/dotnet/CommonLocalizableStrings.resx
@@ -520,4 +520,7 @@
Show help information.
+
+ Does not do an implicit restore when executing the command.
+
\ No newline at end of file
diff --git a/src/dotnet/CommonOptions.cs b/src/dotnet/CommonOptions.cs
index 06047fcd3..e3103b64c 100644
--- a/src/dotnet/CommonOptions.cs
+++ b/src/dotnet/CommonOptions.cs
@@ -65,5 +65,11 @@ namespace Microsoft.DotNet.Cli
public static ArgumentsRule DefaultToCurrentDirectory(this ArgumentsRule rule) =>
rule.With(defaultValue: () => PathUtility.EnsureTrailingSlash(Directory.GetCurrentDirectory()));
+
+ public static Option NoRestoreOption() =>
+ Create.Option(
+ "--no-restore",
+ CommonLocalizableStrings.NoRestoreDescription,
+ Accept.NoArguments());
}
}
\ No newline at end of file
diff --git a/src/dotnet/commands/CommandWithRestoreOptions.cs b/src/dotnet/commands/CommandWithRestoreOptions.cs
new file mode 100644
index 000000000..aaf9748d5
--- /dev/null
+++ b/src/dotnet/commands/CommandWithRestoreOptions.cs
@@ -0,0 +1,39 @@
+// Copyright (c) .NET Foundation and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.DotNet.Cli;
+using Microsoft.DotNet.Cli.CommandLine;
+using Microsoft.DotNet.Tools.MSBuild;
+using Microsoft.DotNet.Tools.Restore;
+
+namespace Microsoft.DotNet.Tools
+{
+ public static class CreateWithRestoreOptions
+ {
+ public static Command Command(
+ string name,
+ string help,
+ ArgumentsRule arguments,
+ params Option[] options)
+ {
+ return Create.Command(name, help, arguments, RestoreCommandParser.AddImplicitRestoreOptions(options));
+ }
+
+ public static Command Command(
+ string name,
+ string help,
+ ArgumentsRule arguments,
+ bool treatUnmatchedTokensAsErrors,
+ params Option[] options)
+ {
+ return Create.Command(
+ name,
+ help,
+ arguments,
+ treatUnmatchedTokensAsErrors,
+ RestoreCommandParser.AddImplicitRestoreOptions(options));
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/dotnet/commands/RestoringCommand.cs b/src/dotnet/commands/RestoringCommand.cs
new file mode 100644
index 000000000..67c114577
--- /dev/null
+++ b/src/dotnet/commands/RestoringCommand.cs
@@ -0,0 +1,56 @@
+// Copyright (c) .NET Foundation and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.DotNet.Tools.MSBuild;
+using Microsoft.DotNet.Tools.Restore;
+
+namespace Microsoft.DotNet.Tools
+{
+ public class RestoringCommand : MSBuildForwardingApp
+ {
+ private bool NoRestore { get; }
+
+ private IEnumerable ArgsToForward { get; }
+
+ private IEnumerable ArgsToForwardToRestore()
+ {
+ var restoreArguments = ArgsToForward.Where(a =>
+ !a.StartsWith("/t:") &&
+ !a.StartsWith("/target:") &&
+ !a.StartsWith("/ConsoleLoggerParameters:") &&
+ !a.StartsWith("/clp:"));
+
+ if (!restoreArguments.Any(a => a.StartsWith("/v:") || a.StartsWith("/verbosity:")))
+ {
+ restoreArguments = restoreArguments.Concat(new string[] { "/v:q" });
+ }
+
+ return restoreArguments;
+ }
+
+ private bool ShouldRunImplicitRestore => !NoRestore;
+
+ public RestoringCommand(IEnumerable msbuildArgs, bool noRestore, string msbuildPath = null)
+ : base(msbuildArgs, msbuildPath)
+ {
+ NoRestore = noRestore;
+ ArgsToForward = msbuildArgs;
+ }
+
+ public override int Execute()
+ {
+ if (ShouldRunImplicitRestore)
+ {
+ int exitCode = RestoreCommand.Run(ArgsToForwardToRestore().ToArray());
+ if (exitCode != 0)
+ {
+ return exitCode;
+ }
+ }
+
+ return base.Execute();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/dotnet/commands/dotnet-build/BuildCommand.cs b/src/dotnet/commands/dotnet-build/BuildCommand.cs
index 691d5ef21..95539c662 100644
--- a/src/dotnet/commands/dotnet-build/BuildCommand.cs
+++ b/src/dotnet/commands/dotnet-build/BuildCommand.cs
@@ -2,18 +2,21 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Collections.Generic;
+using System.Linq;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.MSBuild;
+using Microsoft.DotNet.Tools;
using Microsoft.DotNet.Cli;
+using Microsoft.DotNet.Tools.Restore;
using Parser = Microsoft.DotNet.Cli.Parser;
namespace Microsoft.DotNet.Tools.Build
{
- public class BuildCommand : MSBuildForwardingApp
+ public class BuildCommand : RestoringCommand
{
- public BuildCommand(IEnumerable msbuildArgs, string msbuildPath = null)
- : base(msbuildArgs, msbuildPath)
+ public BuildCommand(IEnumerable msbuildArgs, bool noRestore, string msbuildPath = null)
+ : base(msbuildArgs, noRestore, msbuildPath)
{
}
@@ -44,7 +47,9 @@ namespace Microsoft.DotNet.Tools.Build
msbuildArgs.Add($"/clp:Summary");
- return new BuildCommand(msbuildArgs, msbuildPath);
+ bool noRestore = appliedBuildOptions.HasOption("--no-restore");
+
+ return new BuildCommand(msbuildArgs, noRestore, msbuildPath);
}
public static int Run(string[] args)
diff --git a/src/dotnet/commands/dotnet-build/BuildCommandParser.cs b/src/dotnet/commands/dotnet-build/BuildCommandParser.cs
index eaa00740f..76da0258e 100644
--- a/src/dotnet/commands/dotnet-build/BuildCommandParser.cs
+++ b/src/dotnet/commands/dotnet-build/BuildCommandParser.cs
@@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using System.Collections.Generic;
using System.Linq;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Tools;
@@ -11,7 +12,7 @@ namespace Microsoft.DotNet.Cli
internal static class BuildCommandParser
{
public static Command Build() =>
- Create.Command(
+ CreateWithRestoreOptions.Command(
"build",
LocalizableStrings.AppFullName,
Accept.ZeroOrMoreArguments()
@@ -37,6 +38,7 @@ namespace Microsoft.DotNet.Cli
LocalizableStrings.NoDependenciesOptionDescription,
Accept.NoArguments()
.ForwardAs("/p:BuildProjectReferences=false")),
+ CommonOptions.NoRestoreOption(),
CommonOptions.VerbosityOption());
}
}
\ No newline at end of file
diff --git a/src/dotnet/commands/dotnet-msbuild/MSBuildForwardingApp.cs b/src/dotnet/commands/dotnet-msbuild/MSBuildForwardingApp.cs
index b3edf4abe..dbf81dd6e 100644
--- a/src/dotnet/commands/dotnet-msbuild/MSBuildForwardingApp.cs
+++ b/src/dotnet/commands/dotnet-msbuild/MSBuildForwardingApp.cs
@@ -58,7 +58,7 @@ namespace Microsoft.DotNet.Tools.MSBuild
return ret;
}
- public int Execute()
+ public virtual int Execute()
{
return GetProcessStartInfo().Execute();
}
diff --git a/src/dotnet/commands/dotnet-pack/PackCommand.cs b/src/dotnet/commands/dotnet-pack/PackCommand.cs
index 2821c23d8..0c7146356 100644
--- a/src/dotnet/commands/dotnet-pack/PackCommand.cs
+++ b/src/dotnet/commands/dotnet-pack/PackCommand.cs
@@ -5,16 +5,17 @@ using System.Collections.Generic;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.MSBuild;
+using Microsoft.DotNet.Tools;
using Microsoft.DotNet.Cli;
using System.Diagnostics;
using Parser = Microsoft.DotNet.Cli.Parser;
namespace Microsoft.DotNet.Tools.Pack
{
- public class PackCommand : MSBuildForwardingApp
+ public class PackCommand : RestoringCommand
{
- public PackCommand(IEnumerable msbuildArgs, string msbuildPath = null)
- : base(msbuildArgs, msbuildPath)
+ public PackCommand(IEnumerable msbuildArgs, bool noRestore, string msbuildPath = null)
+ : base(msbuildArgs, noRestore, msbuildPath)
{
}
@@ -30,14 +31,16 @@ namespace Microsoft.DotNet.Tools.Pack
var msbuildArgs = new List()
{
- "/t:pack"
+ "/t:pack"
};
msbuildArgs.AddRange(parsedPack.OptionValuesToBeForwarded());
msbuildArgs.AddRange(parsedPack.Arguments);
- return new PackCommand(msbuildArgs, msbuildPath);
+ bool noRestore = parsedPack.HasOption("--no-restore");
+
+ return new PackCommand(msbuildArgs, noRestore, msbuildPath);
}
public static int Run(string[] args)
diff --git a/src/dotnet/commands/dotnet-pack/PackCommandParser.cs b/src/dotnet/commands/dotnet-pack/PackCommandParser.cs
index 56be1ee3d..036e12072 100644
--- a/src/dotnet/commands/dotnet-pack/PackCommandParser.cs
+++ b/src/dotnet/commands/dotnet-pack/PackCommandParser.cs
@@ -1,8 +1,10 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using System.Collections.Generic;
using System.Linq;
using Microsoft.DotNet.Cli.CommandLine;
+using Microsoft.DotNet.Tools;
using LocalizableStrings = Microsoft.DotNet.Tools.Pack.LocalizableStrings;
namespace Microsoft.DotNet.Cli
@@ -10,7 +12,7 @@ namespace Microsoft.DotNet.Cli
internal static class PackCommandParser
{
public static Command Pack() =>
- Create.Command(
+ CreateWithRestoreOptions.Command(
"pack",
LocalizableStrings.AppFullName,
Accept.ZeroOrMoreArguments(),
@@ -39,6 +41,7 @@ namespace Microsoft.DotNet.Cli
"-s|--serviceable",
LocalizableStrings.CmdServiceableDescription,
Accept.NoArguments().ForwardAs("/p:Serviceable=true")),
+ CommonOptions.NoRestoreOption(),
CommonOptions.VerbosityOption());
}
}
\ No newline at end of file
diff --git a/src/dotnet/commands/dotnet-publish/Program.cs b/src/dotnet/commands/dotnet-publish/Program.cs
index 8c8fbc9cf..d4337e107 100644
--- a/src/dotnet/commands/dotnet-publish/Program.cs
+++ b/src/dotnet/commands/dotnet-publish/Program.cs
@@ -5,15 +5,16 @@ using System.Collections.Generic;
using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Utils;
+using Microsoft.DotNet.Tools;
using Microsoft.DotNet.Tools.MSBuild;
using Parser = Microsoft.DotNet.Cli.Parser;
namespace Microsoft.DotNet.Tools.Publish
{
- public class PublishCommand : MSBuildForwardingApp
+ public class PublishCommand : RestoringCommand
{
- private PublishCommand(IEnumerable msbuildArgs, string msbuildPath = null)
- : base(msbuildArgs, msbuildPath)
+ private PublishCommand(IEnumerable msbuildArgs, bool noRestore, string msbuildPath = null)
+ : base(msbuildArgs, noRestore, msbuildPath)
{
}
@@ -37,7 +38,9 @@ namespace Microsoft.DotNet.Tools.Publish
msbuildArgs.AddRange(appliedPublishOption.Arguments);
- return new PublishCommand(msbuildArgs, msbuildPath);
+ bool noRestore = appliedPublishOption.HasOption("--no-restore");
+
+ return new PublishCommand(msbuildArgs, noRestore, msbuildPath);
}
public static int Run(string[] args)
diff --git a/src/dotnet/commands/dotnet-publish/PublishCommandParser.cs b/src/dotnet/commands/dotnet-publish/PublishCommandParser.cs
index 600d4c459..9149c1dfd 100644
--- a/src/dotnet/commands/dotnet-publish/PublishCommandParser.cs
+++ b/src/dotnet/commands/dotnet-publish/PublishCommandParser.cs
@@ -1,8 +1,10 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using System.Collections.Generic;
using System.Linq;
using Microsoft.DotNet.Cli.CommandLine;
+using Microsoft.DotNet.Tools;
using LocalizableStrings = Microsoft.DotNet.Tools.Publish.LocalizableStrings;
namespace Microsoft.DotNet.Cli
@@ -10,7 +12,7 @@ namespace Microsoft.DotNet.Cli
internal static class PublishCommandParser
{
public static Command Publish() =>
- Create.Command(
+ CreateWithRestoreOptions.Command(
"publish",
LocalizableStrings.AppDescription,
Accept.ZeroOrMoreArguments(),
@@ -41,6 +43,7 @@ namespace Microsoft.DotNet.Cli
string value = o.Arguments.Any() ? o.Arguments.Single() : "true";
return $"/p:SelfContained={value}";
})),
+ CommonOptions.NoRestoreOption(),
CommonOptions.VerbosityOption());
}
}
\ No newline at end of file
diff --git a/src/dotnet/commands/dotnet-restore/Program.cs b/src/dotnet/commands/dotnet-restore/Program.cs
index 65a18e975..b0269370f 100644
--- a/src/dotnet/commands/dotnet-restore/Program.cs
+++ b/src/dotnet/commands/dotnet-restore/Program.cs
@@ -37,7 +37,7 @@ namespace Microsoft.DotNet.Tools.Restore
"/t:Restore"
};
- if (!parsedRestore.HasOption("verbosity"))
+ if (!HasVerbosityOption(parsedRestore))
{
msbuildArgs.Add("/ConsoleLoggerParameters:Verbosity=Minimal");
}
@@ -45,7 +45,7 @@ namespace Microsoft.DotNet.Tools.Restore
msbuildArgs.AddRange(parsedRestore.OptionValuesToBeForwarded());
msbuildArgs.AddRange(parsedRestore.Arguments);
-
+
return new RestoreCommand(msbuildArgs, msbuildPath);
}
@@ -65,5 +65,12 @@ namespace Microsoft.DotNet.Tools.Restore
return cmd.Execute();
}
+
+ private static bool HasVerbosityOption(AppliedOption parsedRestore)
+ {
+ return parsedRestore.HasOption("verbosity") ||
+ parsedRestore.Arguments.Any(a => a.Contains("/v:")) ||
+ parsedRestore.Arguments.Any(a => a.Contains("/verbosity:"));
+ }
}
}
\ No newline at end of file
diff --git a/src/dotnet/commands/dotnet-restore/RestoreCommandParser.cs b/src/dotnet/commands/dotnet-restore/RestoreCommandParser.cs
index a50c464a3..46b17d0f3 100644
--- a/src/dotnet/commands/dotnet-restore/RestoreCommandParser.cs
+++ b/src/dotnet/commands/dotnet-restore/RestoreCommandParser.cs
@@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using System.Collections.Generic;
using System.Linq;
using Microsoft.DotNet.Cli.CommandLine;
using LocalizableStrings = Microsoft.DotNet.Tools.Restore.LocalizableStrings;
@@ -14,15 +15,41 @@ namespace Microsoft.DotNet.Cli
"restore",
LocalizableStrings.AppFullName,
Accept.ZeroOrMoreArguments(),
- CommonOptions.HelpOption(),
+ FullRestoreOptions());
+
+ private static Option[] FullRestoreOptions()
+ {
+ var fullRestoreOptions = AddImplicitRestoreOptions(new Option[] { CommonOptions.HelpOption() }, true, true);
+
+ return fullRestoreOptions.Concat(new Option[] { CommonOptions.VerbosityOption() }).ToArray();
+ }
+
+ public static Option[] AddImplicitRestoreOptions(
+ IEnumerable
diff --git a/test/EndToEnd/GivenNetFrameworkSupportsNetStandard2.cs b/test/EndToEnd/GivenNetFrameworkSupportsNetStandard2.cs
new file mode 100644
index 000000000..97398a685
--- /dev/null
+++ b/test/EndToEnd/GivenNetFrameworkSupportsNetStandard2.cs
@@ -0,0 +1,40 @@
+using FluentAssertions;
+using Microsoft.DotNet.TestFramework;
+using Microsoft.DotNet.Tools.Test.Utilities;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+
+namespace EndToEnd
+{
+ public class GivenNetFrameworkSupportsNetStandard2 : TestBase
+ {
+ [WindowsOnlyFact]
+ public void ANET461ProjectCanReferenceANETStandardProject()
+ {
+ var _testInstance = TestAssets.Get(TestAssetKinds.DesktopTestProjects, "NETFrameworkReferenceNETStandard20")
+ .CreateInstance()
+ .WithSourceFiles();
+
+ string projectDirectory = Path.Combine(_testInstance.Root.FullName, "TestApp");
+
+ new RestoreCommand()
+ .WithWorkingDirectory(projectDirectory)
+ .Execute()
+ .Should().Pass();
+
+ new BuildCommand()
+ .WithWorkingDirectory(projectDirectory)
+ .Execute()
+ .Should().Pass();
+
+ new RunCommand()
+ .WithWorkingDirectory(projectDirectory)
+ .ExecuteWithCapturedOutput()
+ .Should().Pass()
+ .And.HaveStdOutContaining("This string came from the test library!");
+
+ }
+ }
+}
diff --git a/test/dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs b/test/dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs
index 53b01648f..29049f238 100644
--- a/test/dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs
+++ b/test/dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs
@@ -38,6 +38,35 @@ namespace Microsoft.DotNet.Cli.Build.Tests
.And.HaveStdOutContaining("Hello World");
}
+ [Fact]
+ public void ItImplicitlyRestoresAProjectWhenBuilding()
+ {
+ var testAppName = "MSBuildTestApp";
+ var testInstance = TestAssets.Get(testAppName)
+ .CreateInstance(testAppName)
+ .WithSourceFiles();
+
+ new BuildCommand()
+ .WithWorkingDirectory(testInstance.Root)
+ .Execute()
+ .Should().Pass();
+ }
+
+ [Fact]
+ public void ItDoesNotImplicitlyRestoreAProjectWhenBuildingWithTheNoRestoreOption()
+ {
+ var testAppName = "MSBuildTestApp";
+ var testInstance = TestAssets.Get(testAppName)
+ .CreateInstance(testAppName)
+ .WithSourceFiles();
+
+ new BuildCommand()
+ .WithWorkingDirectory(testInstance.Root)
+ .ExecuteWithCapturedOutput("--no-restore")
+ .Should().Fail()
+ .And.HaveStdOutContaining("project.assets.json' not found.");;
+ }
+
[Fact]
public void ItRunsWhenRestoringToSpecificPackageDir()
{
@@ -62,7 +91,7 @@ namespace Microsoft.DotNet.Cli.Build.Tests
new BuildCommand()
.WithWorkingDirectory(rootPath)
- .Execute()
+ .Execute("--no-restore")
.Should().Pass();
var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
diff --git a/test/dotnet-pack.Tests/PackTests.cs b/test/dotnet-pack.Tests/PackTests.cs
index fb4bb42c5..117b6bcc8 100644
--- a/test/dotnet-pack.Tests/PackTests.cs
+++ b/test/dotnet-pack.Tests/PackTests.cs
@@ -158,7 +158,7 @@ namespace Microsoft.DotNet.Tools.Pack.Tests
}
[Fact]
- public void PackWorksWithLocalProjectJson()
+ public void PackWorksWithLocalProject()
{
var testInstance = TestAssets.Get("TestAppSimple")
.CreateInstance()
@@ -171,6 +171,33 @@ namespace Microsoft.DotNet.Tools.Pack.Tests
.Should().Pass();
}
+ [Fact]
+ public void ItImplicitlyRestoresAProjectWhenPackaging()
+ {
+ var testInstance = TestAssets.Get("TestAppSimple")
+ .CreateInstance()
+ .WithSourceFiles();
+
+ new PackCommand()
+ .WithWorkingDirectory(testInstance.Root)
+ .Execute()
+ .Should().Pass();
+ }
+
+ [Fact]
+ public void ItDoesNotImplicitlyRestoreAProjectWhenPackagingWithTheNoRestoreOption()
+ {
+ var testInstance = TestAssets.Get("TestAppSimple")
+ .CreateInstance()
+ .WithSourceFiles();
+
+ new PackCommand()
+ .WithWorkingDirectory(testInstance.Root)
+ .ExecuteWithCapturedOutput("--no-restore")
+ .Should().Fail()
+ .And.HaveStdOutContaining("project.assets.json' not found.");;
+ }
+
[Fact]
public void HasServiceableFlagWhenArgumentPassed()
{
@@ -231,7 +258,7 @@ namespace Microsoft.DotNet.Tools.Pack.Tests
new PackCommand()
.WithWorkingDirectory(rootPath)
- .ExecuteWithCapturedOutput()
+ .ExecuteWithCapturedOutput("--no-restore")
.Should()
.Pass();
diff --git a/test/dotnet-publish.Tests/GivenDotnetPublishPublishesProjects.cs b/test/dotnet-publish.Tests/GivenDotnetPublishPublishesProjects.cs
index f28ded611..80985a5a4 100644
--- a/test/dotnet-publish.Tests/GivenDotnetPublishPublishesProjects.cs
+++ b/test/dotnet-publish.Tests/GivenDotnetPublishPublishesProjects.cs
@@ -44,6 +44,39 @@ namespace Microsoft.DotNet.Cli.Publish.Tests
.And.HaveStdOutContaining("Hello World");
}
+ [Fact]
+ public void ItImplicitlyRestoresAProjectWhenPublishing()
+ {
+ var testAppName = "MSBuildTestApp";
+ var testInstance = TestAssets.Get(testAppName)
+ .CreateInstance()
+ .WithSourceFiles();
+
+ var testProjectDirectory = testInstance.Root.FullName;
+
+ new PublishCommand()
+ .WithWorkingDirectory(testProjectDirectory)
+ .Execute("--framework netcoreapp2.0")
+ .Should().Pass();
+ }
+
+ [Fact]
+ public void ItDoesNotImplicitlyRestoreAProjectWhenPublishingWithTheNoRestoreOption()
+ {
+ var testAppName = "MSBuildTestApp";
+ var testInstance = TestAssets.Get(testAppName)
+ .CreateInstance()
+ .WithSourceFiles();
+
+ var testProjectDirectory = testInstance.Root.FullName;
+
+ new PublishCommand()
+ .WithWorkingDirectory(testProjectDirectory)
+ .ExecuteWithCapturedOutput("--framework netcoreapp2.0 --no-restore")
+ .Should().Fail()
+ .And.HaveStdOutContaining("project.assets.json' not found.");;
+ }
+
[Fact]
public void ItPublishesARunnableSelfContainedApp()
{
@@ -170,7 +203,7 @@ namespace Microsoft.DotNet.Cli.Publish.Tests
new PublishCommand()
.WithWorkingDirectory(rootPath)
- .ExecuteWithCapturedOutput()
+ .ExecuteWithCapturedOutput("--no-restore")
.Should().Pass();
var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
diff --git a/test/dotnet-run.Tests/GivenDotnetRunRunsCsProj.cs b/test/dotnet-run.Tests/GivenDotnetRunRunsCsProj.cs
index 234f890e9..21d1dee1a 100644
--- a/test/dotnet-run.Tests/GivenDotnetRunRunsCsProj.cs
+++ b/test/dotnet-run.Tests/GivenDotnetRunRunsCsProj.cs
@@ -37,6 +37,40 @@ namespace Microsoft.DotNet.Cli.Run.Tests
.And.HaveStdOutContaining("Hello World!");
}
+ [Fact]
+ public void ItImplicitlyRestoresAProjectWhenRunning()
+ {
+ var testAppName = "MSBuildTestApp";
+ var testInstance = TestAssets.Get(testAppName)
+ .CreateInstance()
+ .WithSourceFiles();
+
+ var testProjectDirectory = testInstance.Root.FullName;
+
+ new RunCommand()
+ .WithWorkingDirectory(testProjectDirectory)
+ .ExecuteWithCapturedOutput()
+ .Should().Pass()
+ .And.HaveStdOutContaining("Hello World!");
+ }
+
+ [Fact]
+ public void ItDoesNotImplicitlyRestoreAProjectWhenRunningWithTheNoRestoreOption()
+ {
+ var testAppName = "MSBuildTestApp";
+ var testInstance = TestAssets.Get(testAppName)
+ .CreateInstance()
+ .WithSourceFiles();
+
+ var testProjectDirectory = testInstance.Root.FullName;
+
+ new RunCommand()
+ .WithWorkingDirectory(testProjectDirectory)
+ .ExecuteWithCapturedOutput("--no-restore")
+ .Should().Fail()
+ .And.HaveStdOutContaining("project.assets.json' not found.");;
+ }
+
[Fact]
public void ItBuildsTheProjectBeforeRunning()
{
@@ -160,7 +194,7 @@ namespace Microsoft.DotNet.Cli.Run.Tests
new RunCommand()
.WithWorkingDirectory(rootPath)
- .ExecuteWithCapturedOutput()
+ .ExecuteWithCapturedOutput("--no-restore")
.Should().Pass()
.And.HaveStdOutContaining("Hello World");
}
diff --git a/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs b/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs
index b20fb70ef..1512b9778 100644
--- a/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs
+++ b/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs
@@ -31,6 +31,43 @@ namespace Microsoft.DotNet.Cli.Test.Tests
result.ExitCode.Should().Be(1);
}
+ [Fact]
+ public void ItImplicitlyRestoresAProjectWhenTesting()
+ {
+ string testAppName = "VSTestCore";
+ var testInstance = TestAssets.Get(testAppName)
+ .CreateInstance()
+ .WithSourceFiles();
+
+ var testProjectDirectory = testInstance.Root.FullName;
+
+ CommandResult result = new DotnetTestCommand()
+ .WithWorkingDirectory(testProjectDirectory)
+ .ExecuteWithCapturedOutput(TestBase.ConsoleLoggerOutputNormal);
+
+ result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.");
+ result.StdOut.Should().Contain("Passed TestNamespace.VSTestTests.VSTestPassTest");
+ result.StdOut.Should().Contain("Failed TestNamespace.VSTestTests.VSTestFailTest");
+ result.ExitCode.Should().Be(1);
+ }
+
+ [Fact]
+ public void ItDoesNotImplicitlyRestoreAProjectWhenTestingWithTheNoRestoreOption()
+ {
+ string testAppName = "VSTestCore";
+ var testInstance = TestAssets.Get(testAppName)
+ .CreateInstance()
+ .WithSourceFiles();
+
+ var testProjectDirectory = testInstance.Root.FullName;
+
+ new DotnetTestCommand()
+ .WithWorkingDirectory(testProjectDirectory)
+ .ExecuteWithCapturedOutput($"{TestBase.ConsoleLoggerOutputNormal} --no-restore")
+ .Should().Fail()
+ .And.HaveStdOutContaining("project.assets.json' not found.");;
+ }
+
[Fact]
public void XunitSingleTFM()
{
@@ -161,14 +198,14 @@ namespace Microsoft.DotNet.Cli.Test.Tests
new BuildCommand()
.WithWorkingDirectory(rootPath)
- .ExecuteWithCapturedOutput()
+ .ExecuteWithCapturedOutput("--no-restore")
.Should()
.Pass()
.And.NotHaveStdErr();
CommandResult result = new DotnetTestCommand()
.WithWorkingDirectory(rootPath)
- .ExecuteWithCapturedOutput(TestBase.ConsoleLoggerOutputNormal);
+ .ExecuteWithCapturedOutput($"{TestBase.ConsoleLoggerOutputNormal} --no-restore");
result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.");
result.StdOut.Should().Contain("Passed TestNamespace.VSTestTests.VSTestPassTest");
@@ -209,6 +246,7 @@ namespace Microsoft.DotNet.Cli.Test.Tests
.Execute()
.Should()
.Pass();
+
return testProjectDirectory;
}
}