Merge branch 'rel/1.0.0' into clitest3verb

This commit is contained in:
Faizan Ahmad 2016-10-12 11:57:46 +05:30
commit 391fff1f20
95 changed files with 735 additions and 854 deletions

View file

@ -15,7 +15,7 @@
"dotnet-desktop-binding-redirects": "1.0.0-*" "dotnet-desktop-binding-redirects": "1.0.0-*"
}, },
"frameworks": { "frameworks": {
"net451": {} "net46": {}
}, },
"tools": { "tools": {
"dotnet-dependency-tool-invoker": { "dotnet-dependency-tool-invoker": {

View file

@ -15,7 +15,7 @@
"dotnet-desktop-binding-redirects": "1.0.0-*" "dotnet-desktop-binding-redirects": "1.0.0-*"
}, },
"frameworks": { "frameworks": {
"net451": {} "net46": {}
}, },
"tools": { "tools": {
"dotnet-dependency-tool-invoker": { "dotnet-dependency-tool-invoker": {

View file

@ -1,21 +0,0 @@
using System;
using Microsoft.DotNet.Cli.Utils;
using System.IO;
namespace DesktopAppWhichCallsDotnet
{
public class Program
{
public static int Main(string[] args)
{
var projectPath = args[0];
return Command.CreateDotNet("build", new string[] {})
.WorkingDirectory(Path.GetDirectoryName(projectPath))
.ForwardStdErr()
.ForwardStdOut()
.Execute()
.ExitCode;
}
}
}

View file

@ -1,14 +0,0 @@
{
"version": "1.0.0-*",
"dependencies": {
"Microsoft.DotNet.Cli.Utils": {
"target": "project"
}
},
"buildOptions": {
"emitEntryPoint": true
},
"frameworks": {
"net451": {}
}
}

View file

@ -16,8 +16,9 @@
<PackageReference Include="Microsoft.NETCore.App"> <PackageReference Include="Microsoft.NETCore.App">
<Version>1.0.1</Version> <Version>1.0.1</Version>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.NETCore.Sdk"> <PackageReference Include="Microsoft.NET.Sdk">
<Version>1.0.0-alpha-20161007-1</Version> <Version>1.0.0-alpha-20161010-1</Version>
<PrivateAssets>All</PrivateAssets>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>

View file

@ -8,14 +8,14 @@ namespace FakeTests
{ {
public class GivenThatIWantSomeFakeTests public class GivenThatIWantSomeFakeTests
{ {
#if NET451 #if NET46
[Fact] [Fact]
public void NET451_succeeds() public void NET46_succeeds()
{ {
Assert.True(true); Assert.True(true);
} }
[Fact(Skip="Skipped for NET451")] [Fact(Skip="Skipped for NET46")]
public void SkippedTest() public void SkippedTest()
{ {
@ -45,8 +45,8 @@ namespace FakeTests
{ {
var shouldFail = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DOTNET_TEST_SHOULD_FAIL")); var shouldFail = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DOTNET_TEST_SHOULD_FAIL"));
#if NET451 #if NET46
Assert.True(shouldFail, "Failing in NET451"); Assert.True(shouldFail, "Failing in NET46");
#else #else
Assert.True(shouldFail, "Failing in NETCOREAPP1.0"); Assert.True(shouldFail, "Failing in NETCOREAPP1.0");
#endif #endif

View file

@ -20,7 +20,11 @@
"System.Runtime.Serialization.Primitives": "4.1.1" "System.Runtime.Serialization.Primitives": "4.1.1"
} }
}, },
"net451": {} "net46": {
"dependencies": {
"System.IO.FileSystem": "4.0.1"
}
}
}, },
"testRunner": "xunit" "testRunner": "xunit"
} }

View file

@ -3,7 +3,7 @@
"frameworks": { "frameworks": {
"netstandard1.5": { "netstandard1.5": {
"dependencies": { "dependencies": {
"Microsoft.NETCore.Sdk": "1.0.0-alpha-20160923-4", "Microsoft.NET.Sdk": "1.0.0-alpha-20161010-1",
"NETStandard.Library": "1.6.0" "NETStandard.Library": "1.6.0"
} }
} }

View file

@ -3,7 +3,7 @@
"frameworks": { "frameworks": {
"netstandard1.5": { "netstandard1.5": {
"dependencies": { "dependencies": {
"Microsoft.NETCore.Sdk": "1.0.0-alpha-20160923-4", "Microsoft.NET.Sdk": "1.0.0-alpha-20161010-1",
"NETStandard.Library": "1.6.0" "NETStandard.Library": "1.6.0"
} }
} }

View file

@ -3,7 +3,7 @@
"frameworks": { "frameworks": {
"netstandard1.5": { "netstandard1.5": {
"dependencies": { "dependencies": {
"Microsoft.NETCore.Sdk": "1.0.0-alpha-20160923-4", "Microsoft.NET.Sdk": "1.0.0-alpha-20161010-1",
"NETStandard.Library": "1.6.0" "NETStandard.Library": "1.6.0"
} }
} }

View file

@ -16,8 +16,9 @@
<PackageReference Include="Microsoft.NETCore.App"> <PackageReference Include="Microsoft.NETCore.App">
<Version>1.0.1</Version> <Version>1.0.1</Version>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.NETCore.Sdk"> <PackageReference Include="Microsoft.NET.Sdk">
<Version>1.0.0-alpha-20161007-1</Version> <Version>1.0.0-alpha-20161010-1</Version>
<PrivateAssets>All</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="MSTest.TestFramework"> <PackageReference Include="MSTest.TestFramework">
<Version>1.0.4-preview</Version> <Version>1.0.4-preview</Version>

View file

@ -16,7 +16,7 @@
DependsOnTargets="BuildDotnetCliBuildFramework" > DependsOnTargets="BuildDotnetCliBuildFramework" >
<!-- Current Runtime Information --> <!-- Current Runtime Information -->
<GetCurrentRuntimeInformation> <GetCurrentRuntimeInformation OverrideRid="$(OverrideRid)">
<Output TaskParameter="Rid" PropertyName="Rid" /> <Output TaskParameter="Rid" PropertyName="Rid" />
<Output TaskParameter="Architecture" PropertyName="Architecture" /> <Output TaskParameter="Architecture" PropertyName="Architecture" />
<Output TaskParameter="OSName" PropertyName="OSName" /> <Output TaskParameter="OSName" PropertyName="OSName" />

View file

@ -175,7 +175,7 @@
<Message Text="%(NoAutoBuildDesktopTestAssetProjects.FullPath)" /> <Message Text="%(NoAutoBuildDesktopTestAssetProjects.FullPath)" />
<DotNetBuild Configuration="$(Configuration)" <DotNetBuild Configuration="$(Configuration)"
Framework="net451" Framework="net46"
ProjectPath="%(BuildableDesktopTestAssetProjects.FullPath)" ProjectPath="%(BuildableDesktopTestAssetProjects.FullPath)"
ToolPath="$(DotnetUnderTest)" ToolPath="$(DotnetUnderTest)"
WorkingDirectory="%(BuildableDesktopTestAssetProjects.RelativeDir)" /> WorkingDirectory="%(BuildableDesktopTestAssetProjects.RelativeDir)" />

View file

@ -26,6 +26,12 @@
<SdkInstallerNupkgFile>$(InstallerOutputDirectory)/VS.Redist.Common.Net.Core.SDK.$(Architecture).$(NugetVersion).nupkg</SdkInstallerNupkgFile> <SdkInstallerNupkgFile>$(InstallerOutputDirectory)/VS.Redist.Common.Net.Core.SDK.$(Architecture).$(NugetVersion).nupkg</SdkInstallerNupkgFile>
</PropertyGroup> </PropertyGroup>
<!-- Generate SDK MSI Inputs -->
<ItemGroup>
<GenerateSdkMsiInputs Include="$(SdkLayoutOutputDirectory)/**/*;
$(SdkGenerateMsiPowershellScript)" />
</ItemGroup>
<!-- Consumed By Publish --> <!-- Consumed By Publish -->
<ItemGroup> <ItemGroup>
<GeneratedInstallers Include="$(SdkInstallerFile);$(CombinedFrameworkSdkHostInstallerFile)" /> <GeneratedInstallers Include="$(SdkInstallerFile);$(CombinedFrameworkSdkHostInstallerFile)" />
@ -75,8 +81,7 @@
<Target Name="GenerateSdkMsi" <Target Name="GenerateSdkMsi"
DependsOnTargets="Init;Layout;AcquireWix;MsiTargetsSetupInputOutputs" DependsOnTargets="Init;Layout;AcquireWix;MsiTargetsSetupInputOutputs"
Condition=" '$(OS)' == 'Windows_NT'" Condition=" '$(OS)' == 'Windows_NT'"
Inputs="$(SdkLayoutOutputDirectory); Inputs="@(GenerateSdkMsiInputs)"
$(SdkGenerateMsiPowershellScript)"
Outputs="$(SdkInstallerFile)"> Outputs="$(SdkInstallerFile)">
<Exec Command="powershell -NoProfile -NoLogo $(SdkGenerateMsiPowershellScript) <Exec Command="powershell -NoProfile -NoLogo $(SdkGenerateMsiPowershellScript)

View file

@ -159,7 +159,7 @@
<VersionPrefix>1.0.0-preview3-</VersionPrefix> <VersionPrefix>1.0.0-preview3-</VersionPrefix>
<VersionSuffix>$(TestPackageBuildVersionSuffix)</VersionSuffix> <VersionSuffix>$(TestPackageBuildVersionSuffix)</VersionSuffix>
<Clean>False</Clean> <Clean>False</Clean>
<Frameworks>net451;netstandard1.6</Frameworks> <Frameworks>netstandard1.3</Frameworks>
</BaseTestPackageProject> </BaseTestPackageProject>
<BaseTestPackageProject Include="src/Microsoft.DotNet.ProjectModel"> <BaseTestPackageProject Include="src/Microsoft.DotNet.ProjectModel">
<Name>Microsoft.DotNet.ProjectModel</Name> <Name>Microsoft.DotNet.ProjectModel</Name>
@ -168,7 +168,7 @@
<VersionPrefix>1.0.0-rc4-</VersionPrefix> <VersionPrefix>1.0.0-rc4-</VersionPrefix>
<VersionSuffix>$(TestPackageBuildVersionSuffix)</VersionSuffix> <VersionSuffix>$(TestPackageBuildVersionSuffix)</VersionSuffix>
<Clean>False</Clean> <Clean>False</Clean>
<Frameworks>net451;netstandard1.6</Frameworks> <Frameworks>netstandard1.3</Frameworks>
</BaseTestPackageProject> </BaseTestPackageProject>
<BaseTestPackageProject Include="src/Microsoft.DotNet.ProjectModel.Loader"> <BaseTestPackageProject Include="src/Microsoft.DotNet.ProjectModel.Loader">
<Name>Microsoft.DotNet.ProjectModel.Loader</Name> <Name>Microsoft.DotNet.ProjectModel.Loader</Name>
@ -186,7 +186,7 @@
<VersionPrefix>1.0.0-preview3-</VersionPrefix> <VersionPrefix>1.0.0-preview3-</VersionPrefix>
<VersionSuffix>$(TestPackageBuildVersionSuffix)</VersionSuffix> <VersionSuffix>$(TestPackageBuildVersionSuffix)</VersionSuffix>
<Clean>False</Clean> <Clean>False</Clean>
<Frameworks>netstandard1.6</Frameworks> <Frameworks>netstandard1.3</Frameworks>
</BaseTestPackageProject> </BaseTestPackageProject>
<BaseTestPackageProject Include="src/Microsoft.DotNet.InternalAbstractions"> <BaseTestPackageProject Include="src/Microsoft.DotNet.InternalAbstractions">
<Name>Microsoft.DotNet.InternalAbstractions</Name> <Name>Microsoft.DotNet.InternalAbstractions</Name>
@ -195,7 +195,7 @@
<VersionPrefix>1.0.1-beta-</VersionPrefix> <VersionPrefix>1.0.1-beta-</VersionPrefix>
<VersionSuffix>$(TestPackageBuildVersionSuffix)</VersionSuffix> <VersionSuffix>$(TestPackageBuildVersionSuffix)</VersionSuffix>
<Clean>False</Clean> <Clean>False</Clean>
<Frameworks>net451;netstandard1.3</Frameworks> <Frameworks>netstandard1.3</Frameworks>
</BaseTestPackageProject> </BaseTestPackageProject>
<BaseTestPackageProject Include="src/Microsoft.Extensions.Testing.Abstractions"> <BaseTestPackageProject Include="src/Microsoft.Extensions.Testing.Abstractions">
<Name>Microsoft.Extensions.Testing.Abstractions</Name> <Name>Microsoft.Extensions.Testing.Abstractions</Name>
@ -204,7 +204,7 @@
<VersionPrefix>1.0.0-preview3-</VersionPrefix> <VersionPrefix>1.0.0-preview3-</VersionPrefix>
<VersionSuffix>$(TestPackageBuildVersionSuffix)</VersionSuffix> <VersionSuffix>$(TestPackageBuildVersionSuffix)</VersionSuffix>
<Clean>False</Clean> <Clean>False</Clean>
<Frameworks>net451;netstandard1.6</Frameworks> <Frameworks>netstandard1.3</Frameworks>
</BaseTestPackageProject> </BaseTestPackageProject>
<BaseTestPackageProject Include="src/Microsoft.DotNet.Compiler.Common"> <BaseTestPackageProject Include="src/Microsoft.DotNet.Compiler.Common">
<Name>Microsoft.DotNet.Compiler.Common</Name> <Name>Microsoft.DotNet.Compiler.Common</Name>
@ -213,7 +213,7 @@
<VersionPrefix>1.0.0-preview3-</VersionPrefix> <VersionPrefix>1.0.0-preview3-</VersionPrefix>
<VersionSuffix>$(TestPackageBuildVersionSuffix)</VersionSuffix> <VersionSuffix>$(TestPackageBuildVersionSuffix)</VersionSuffix>
<Clean>False</Clean> <Clean>False</Clean>
<Frameworks>netstandard1.6</Frameworks> <Frameworks>netstandard1.3</Frameworks>
</BaseTestPackageProject> </BaseTestPackageProject>
<BaseTestPackageProject Include="src/Microsoft.DotNet.Files"> <BaseTestPackageProject Include="src/Microsoft.DotNet.Files">
<Name>Microsoft.DotNet.Files</Name> <Name>Microsoft.DotNet.Files</Name>
@ -222,16 +222,7 @@
<VersionPrefix>1.0.0-preview3-</VersionPrefix> <VersionPrefix>1.0.0-preview3-</VersionPrefix>
<VersionSuffix>$(TestPackageBuildVersionSuffix)</VersionSuffix> <VersionSuffix>$(TestPackageBuildVersionSuffix)</VersionSuffix>
<Clean>False</Clean> <Clean>False</Clean>
<Frameworks>netstandard1.6</Frameworks> <Frameworks>netstandard1.3</Frameworks>
</BaseTestPackageProject>
<BaseTestPackageProject Include="src/dotnet-compile-fsc">
<Name>dotnet-compile-fsc</Name>
<IsTool>True</IsTool>
<IsApplicable>True</IsApplicable>
<VersionPrefix>1.0.0-preview3-</VersionPrefix>
<VersionSuffix>$(TestPackageBuildVersionSuffix)</VersionSuffix>
<Clean>True</Clean>
<Frameworks>netcoreapp1.0</Frameworks>
</BaseTestPackageProject> </BaseTestPackageProject>
<TestPackageProjectFrameworksExcludes Condition=" '$(IsDesktopAvailable)' != 'True' " Include="net45" /> <TestPackageProjectFrameworksExcludes Condition=" '$(IsDesktopAvailable)' != 'True' " Include="net45" />

View file

@ -38,9 +38,6 @@
Include="test$(PathSeparator)TestingAbstractions$(PathSeparator)Microsoft.Extensions.Testing.Abstractions.Tests$(PathSeparator)project.json; Include="test$(PathSeparator)TestingAbstractions$(PathSeparator)Microsoft.Extensions.Testing.Abstractions.Tests$(PathSeparator)project.json;
test$(PathSeparator)TestingAbstractions$(PathSeparator)Microsoft.Extensions.Testing.Abstractions.UnitTests$(PathSeparator)project.json;" /> test$(PathSeparator)TestingAbstractions$(PathSeparator)Microsoft.Extensions.Testing.Abstractions.UnitTests$(PathSeparator)project.json;" />
<PreTestProjectsToExclude Condition=" 'https://github.com/dotnet/cli/issues/3558' != 'fixed' "
Include="test$(PathSeparator)dotnet-compile-fsc.Tests$(PathSeparator)project.json" />
<PreTestProjectsToExclude Condition=" 'https://github.com/dotnet/cli/issues/3216' != 'fixed' " <PreTestProjectsToExclude Condition=" 'https://github.com/dotnet/cli/issues/3216' != 'fixed' "
Include="test$(PathSeparator)Kestrel.Tests$(PathSeparator)project.json" /> Include="test$(PathSeparator)Kestrel.Tests$(PathSeparator)project.json" />
@ -86,7 +83,7 @@
</TestProjects> </TestProjects>
<TestProjects Condition=" '%(RelativeDir)' == 'test\binding-redirects.Tests\' "> <TestProjects Condition=" '%(RelativeDir)' == 'test\binding-redirects.Tests\' ">
<Framework>net451</Framework> <Framework>net46</Framework>
</TestProjects> </TestProjects>
<TestProjects Condition=" '%(RelativeDir)' == 'test\Installer\Microsoft.DotNet.Cli.Msi.Tests\' "> <TestProjects Condition=" '%(RelativeDir)' == 'test\Installer\Microsoft.DotNet.Cli.Msi.Tests\' ">
<Framework>net46</Framework> <Framework>net46</Framework>

View file

@ -9,6 +9,8 @@ namespace Microsoft.DotNet.Cli.Build
{ {
public class GetCurrentRuntimeInformation : Task public class GetCurrentRuntimeInformation : Task
{ {
public string OverrideRid { get; set; }
[Output] [Output]
public string Rid { get; set; } public string Rid { get; set; }
@ -20,7 +22,7 @@ namespace Microsoft.DotNet.Cli.Build
public override bool Execute() public override bool Execute()
{ {
Rid = RuntimeEnvironment.GetRuntimeIdentifier(); Rid = string.IsNullOrEmpty(OverrideRid) ? RuntimeEnvironment.GetRuntimeIdentifier() : OverrideRid;
Architecture = RuntimeEnvironment.RuntimeArchitecture; Architecture = RuntimeEnvironment.RuntimeArchitecture;
OSName = Monikers.GetOSShortName(); OSName = Monikers.GetOSShortName();

View file

@ -47,6 +47,8 @@
.PARAMETER AzureFeed .PARAMETER AzureFeed
Default: https://dotnetcli.azureedge.net/dotnet Default: https://dotnetcli.azureedge.net/dotnet
This parameter should not be usually changed by user. It allows to change URL for the Azure feed used by this installer. This parameter should not be usually changed by user. It allows to change URL for the Azure feed used by this installer.
.PARAMETER ProxyAddress
If set, the installer will use the proxy when making web requests
#> #>
[cmdletbinding()] [cmdletbinding()]
param( param(
@ -59,7 +61,8 @@ param(
[switch]$DryRun, [switch]$DryRun,
[switch]$NoPath, [switch]$NoPath,
[string]$AzureFeed="https://dotnetcli.azureedge.net/dotnet", [string]$AzureFeed="https://dotnetcli.azureedge.net/dotnet",
[string]$UncachedFeed="https://dotnetcli.blob.core.windows.net/dotnet" [string]$UncachedFeed="https://dotnetcli.blob.core.windows.net/dotnet",
[string]$ProxyAddress
) )
Set-StrictMode -Version Latest Set-StrictMode -Version Latest
@ -133,7 +136,15 @@ function GetHTTPResponse([Uri] $Uri)
try { try {
# HttpClient is used vs Invoke-WebRequest in order to support Nano Server which doesn't support the Invoke-WebRequest cmdlet. # HttpClient is used vs Invoke-WebRequest in order to support Nano Server which doesn't support the Invoke-WebRequest cmdlet.
Load-Assembly -Assembly System.Net.Http Load-Assembly -Assembly System.Net.Http
$HttpClient = New-Object System.Net.Http.HttpClient if($ProxyAddress){
$HttpClientHandler = New-Object System.Net.Http.HttpClientHandler
$HttpClientHandler.Proxy = New-Object System.Net.WebProxy -Property @{Address=$ProxyAddress}
$HttpClient = New-Object System.Net.Http.HttpClient -ArgumentList $HttpClientHandler
}
else {
$HttpClient = New-Object System.Net.Http.HttpClient
}
$Response = $HttpClient.GetAsync($Uri).Result $Response = $HttpClient.GetAsync($Uri).Result
if (($Response -eq $null) -or (-not ($Response.IsSuccessStatusCode))) if (($Response -eq $null) -or (-not ($Response.IsSuccessStatusCode)))
{ {

View file

@ -80,7 +80,7 @@ namespace Microsoft.DotNet.Cli.Utils
var projectContext = ProjectContext.Create( var projectContext = ProjectContext.Create(
projectRootPath, projectRootPath,
framework, framework,
DotnetRuntimeIdentifiers.InferCurrentRuntimeIdentifiers()); RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers());
if (projectContext.RuntimeIdentifier == null) if (projectContext.RuntimeIdentifier == null)
{ {

View file

@ -142,8 +142,7 @@ namespace Microsoft.DotNet.Cli.Utils
return ProjectContext.Create( return ProjectContext.Create(
projectRootPath, projectRootPath,
framework, framework,
DotnetRuntimeIdentifiers.InferCurrentRuntimeIdentifiers()); RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers());
} }
private IEnumerable<string> GetAllowedCommandExtensionsFromEnvironment(IEnvironmentProvider environment) private IEnumerable<string> GetAllowedCommandExtensionsFromEnvironment(IEnvironmentProvider environment)

View file

@ -8,7 +8,7 @@ namespace Microsoft.DotNet.Cli.Utils
{ {
internal static class DotnetRuntimeIdentifiers internal static class DotnetRuntimeIdentifiers
{ {
public static IEnumerable<string> InferCurrentRuntimeIdentifiers() public static IEnumerable<string> InferCurrentRuntimeIdentifiers(DotnetVersionFile versionFile)
{ {
IEnumerable<string> fallbackIdentifiers = null; IEnumerable<string> fallbackIdentifiers = null;
@ -22,7 +22,7 @@ namespace Microsoft.DotNet.Cli.Utils
FrameworkDependencyFile fxDepsFile = new FrameworkDependencyFile(); FrameworkDependencyFile fxDepsFile = new FrameworkDependencyFile();
if (!fxDepsFile.SupportsCurrentRuntime()) if (!fxDepsFile.SupportsCurrentRuntime())
{ {
string buildRid = DotnetFiles.VersionFileObject.BuildRid; string buildRid = versionFile.BuildRid;
if (!string.IsNullOrEmpty(buildRid)) if (!string.IsNullOrEmpty(buildRid))
{ {
fallbackIdentifiers = new string[] { buildRid }; fallbackIdentifiers = new string[] { buildRid };

View file

@ -5,3 +5,4 @@ using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("dotnet, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("dotnet, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.DotNet.Tools.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.DotNet.Tools.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.DotNet.Cli.Utils.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.DotNet.Cli.Utils.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.DotNet.Tools.Tests.Utilities, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]

View file

@ -15,14 +15,7 @@
"NuGet.ProjectModel": "3.6.0-rc-1954" "NuGet.ProjectModel": "3.6.0-rc-1954"
}, },
"frameworks": { "frameworks": {
"net451": { "netstandard1.3": {
"frameworkAssemblies": {
"System.Runtime": {
"type": "build"
}
}
},
"netstandard1.6": {
"imports": [ "imports": [
"portable-net45+wp80+win8+wpa81+dnxcore50" "portable-net45+wp80+win8+wpa81+dnxcore50"
], ],

View file

@ -17,26 +17,7 @@
"NuGet.ProjectModel": "3.6.0-rc-1954" "NuGet.ProjectModel": "3.6.0-rc-1954"
}, },
"frameworks": { "frameworks": {
"net451": { "netstandard1.3": {
"frameworkAssemblies": {
"System.Runtime": {
"type": "build"
},
"System.Collections": {
"type": "build"
},
"System.IO": {
"type": "build"
},
"System.Threading.Tasks": {
"type": "build"
},
"System.Text.Encoding": {
"type": "build"
}
}
},
"netstandard1.6": {
"imports": [ "imports": [
"portable-net45+wp80+win8+wpa81+dnxcore50" "portable-net45+wp80+win8+wpa81+dnxcore50"
] ]

View file

@ -1,7 +1,8 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved. // 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. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Microsoft.DotNet.Cli.Utils; using System;
using System.IO;
using Microsoft.DotNet.Archive; using Microsoft.DotNet.Archive;
using Microsoft.Extensions.EnvironmentAbstractions; using Microsoft.Extensions.EnvironmentAbstractions;
@ -11,8 +12,9 @@ namespace Microsoft.DotNet.Configurer
{ {
private ITemporaryDirectory _temporaryDirectory; private ITemporaryDirectory _temporaryDirectory;
public string NuGetPackagesArchive => DotnetFiles.NuGetPackagesArchive; public string NuGetPackagesArchive =>
Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "nuGetPackagesArchive.lzma"));
public NuGetPackagesArchiver() : this(FileSystemWrapper.Default.Directory) public NuGetPackagesArchiver() : this(FileSystemWrapper.Default.Directory)
{ {
} }

View file

@ -14,20 +14,7 @@
"System.Linq.Expressions": "4.1.0" "System.Linq.Expressions": "4.1.0"
}, },
"frameworks": { "frameworks": {
"net451": { "netstandard1.3": {
"frameworkAssemblies": {
"System.Runtime": {
"type": "build"
},
"System.Collections": {
"type": "build"
},
"System.IO": {
"type": "build"
}
}
},
"netstandard1.6": {
"imports": [ "imports": [
"portable-net45+wp80+win8+wpa81+dnxcore50" "portable-net45+wp80+win8+wpa81+dnxcore50"
] ]

View file

@ -7,7 +7,6 @@
"allowUnsafe": true "allowUnsafe": true
}, },
"frameworks": { "frameworks": {
"net451": {},
"netstandard1.3": { "netstandard1.3": {
"dependencies": { "dependencies": {
"System.AppContext": "4.1.0", "System.AppContext": "4.1.0",

View file

@ -5,6 +5,6 @@ namespace Microsoft.DotNet.ProjectJsonMigration
{ {
public class ConstantPackageNames public class ConstantPackageNames
{ {
public const string CSdkPackageName = "Microsoft.NETCore.Sdk"; public const string CSdkPackageName = "Microsoft.NET.Sdk";
} }
} }

View file

@ -11,6 +11,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Models
private readonly string _metadataValue; private readonly string _metadataValue;
private readonly Func<T, string> _metadataValueFunc; private readonly Func<T, string> _metadataValueFunc;
private readonly Func<T, bool> _writeMetadataConditionFunc;
public ItemMetadataValue(string metadataName, string metadataValue) public ItemMetadataValue(string metadataName, string metadataValue)
{ {
@ -18,10 +19,16 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Models
_metadataValue = metadataValue; _metadataValue = metadataValue;
} }
public ItemMetadataValue(string metadataName, Func<T, string> metadataValueFunc) public ItemMetadataValue(string metadataName, Func<T, string> metadataValueFunc, Func<T, bool> writeMetadataConditionFunc = null)
{ {
MetadataName = metadataName; MetadataName = metadataName;
_metadataValueFunc = metadataValueFunc; _metadataValueFunc = metadataValueFunc;
_writeMetadataConditionFunc = writeMetadataConditionFunc;
}
public bool ShouldWriteMetadata(T source)
{
return _writeMetadataConditionFunc == null || _writeMetadataConditionFunc(source);
} }
public string GetMetadataValue(T source) public string GetMetadataValue(T source)

View file

@ -43,7 +43,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
new PackageDependencyInfo new PackageDependencyInfo
{ {
Name = ConstantPackageNames.CSdkPackageName, Name = ConstantPackageNames.CSdkPackageName,
Version = migrationSettings.SdkPackageVersion Version = migrationSettings.SdkPackageVersion,
PrivateAssets = "All"
}), migrationRuleInputs.CommonItemGroup); }), migrationRuleInputs.CommonItemGroup);
// Migrate Direct Deps first // Migrate Direct Deps first
@ -59,7 +60,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
{ {
MigrationTrace.Instance.WriteLine($"Migrating framework {targetFramework.FrameworkName.GetShortFolderName()}"); MigrationTrace.Instance.WriteLine($"Migrating framework {targetFramework.FrameworkName.GetShortFolderName()}");
MigrateImports(migrationRuleInputs.CommonItemGroup, targetFramework); MigrateImports(migrationRuleInputs.CommonPropertyGroup, targetFramework);
MigrateDependencies( MigrateDependencies(
project, project,
@ -69,17 +70,21 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
migrationRuleInputs.ProjectXproj); migrationRuleInputs.ProjectXproj);
} }
// Tools
MigrateTools(project, migrationRuleInputs.OutputMSBuildProject); MigrateTools(project, migrationRuleInputs.OutputMSBuildProject);
} }
private void MigrateImports(ProjectItemGroupElement commonItemGroup, TargetFrameworkInformation targetFramework) private void MigrateImports(ProjectPropertyGroupElement commonPropertyGroup, TargetFrameworkInformation targetFramework)
{ {
var transform = ImportsTransformation.Transform(targetFramework); var transform = ImportsTransformation.Transform(targetFramework);
if (transform != null) if (transform != null)
{ {
transform.Condition = targetFramework.FrameworkName.GetMSBuildCondition(); transform.Condition = targetFramework.FrameworkName.GetMSBuildCondition();
_transformApplicator.Execute(transform, commonItemGroup); _transformApplicator.Execute(transform, commonPropertyGroup);
}
else
{
MigrationTrace.Instance.WriteLine($"{nameof(MigratePackageDependenciesAndToolsRule)}: imports transform null for {targetFramework.FrameworkName.GetShortFolderName()}");
} }
} }
@ -128,7 +133,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
itemGroup.Condition = condition; itemGroup.Condition = condition;
foreach (var packageDependency in packageDependencies) foreach (var packageDependency in packageDependencies)
{ {
MigrationTrace.Instance.WriteLine(packageDependency.Name); MigrationTrace.Instance.WriteLine(packageDependency.Name);
AddItemTransform<ProjectLibraryDependency> transform; AddItemTransform<ProjectLibraryDependency> transform;
@ -139,9 +144,9 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
else else
{ {
transform = PackageDependencyTransform(); transform = PackageDependencyTransform();
if (packageDependency.Type == LibraryDependencyType.Build) if (packageDependency.Type.Equals(LibraryDependencyType.Build))
{ {
transform = transform.WithMetadata("PrivateAssets", "all"); transform = transform.WithMetadata("PrivateAssets", "All");
} }
else if (packageDependency.SuppressParent != LibraryIncludeFlagUtils.DefaultSuppressParent) else if (packageDependency.SuppressParent != LibraryIncludeFlagUtils.DefaultSuppressParent)
{ {
@ -162,11 +167,16 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
private string ReadLibraryIncludeFlags(LibraryIncludeFlags includeFlags) private string ReadLibraryIncludeFlags(LibraryIncludeFlags includeFlags)
{ {
if ((includeFlags & LibraryIncludeFlags.All) == LibraryIncludeFlags.All) if ((includeFlags ^ LibraryIncludeFlags.All) == 0)
{ {
return "All"; return "All";
} }
if ((includeFlags ^ LibraryIncludeFlags.None) == 0)
{
return "None";
}
var flagString = ""; var flagString = "";
var allFlagsAndNames = new List<Tuple<string, LibraryIncludeFlags>> var allFlagsAndNames = new List<Tuple<string, LibraryIncludeFlags>>
{ {
@ -228,7 +238,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
dep => dep.Name, dep => dep.Name,
dep => "", dep => "",
dep => true) dep => true)
.WithMetadata("Version", r => r.Version); .WithMetadata("Version", r => r.Version)
.WithMetadata("PrivateAssets", r => r.PrivateAssets, r => !string.IsNullOrEmpty(r.PrivateAssets));
private AddItemTransform<ProjectLibraryDependency> ToolTransform => new AddItemTransform<ProjectLibraryDependency>( private AddItemTransform<ProjectLibraryDependency> ToolTransform => new AddItemTransform<ProjectLibraryDependency>(
"DotNetCliToolReference", "DotNetCliToolReference",
@ -237,16 +248,16 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
dep => true) dep => true)
.WithMetadata("Version", r => r.LibraryRange.VersionRange.OriginalString); .WithMetadata("Version", r => r.LibraryRange.VersionRange.OriginalString);
private AddItemTransform<TargetFrameworkInformation> ImportsTransformation => new AddItemTransform<TargetFrameworkInformation>( private AddPropertyTransform<TargetFrameworkInformation> ImportsTransformation => new AddPropertyTransform<TargetFrameworkInformation>(
"PackageTargetFallback", "PackageTargetFallback",
t => $"$(PackageTargetFallback);{string.Join(";", t.Imports)}", t => $"$(PackageTargetFallback);{string.Join(";", t.Imports)}",
t => "",
t => t.Imports.OrEmptyIfNull().Any()); t => t.Imports.OrEmptyIfNull().Any());
private class PackageDependencyInfo private class PackageDependencyInfo
{ {
public string Name {get; set;} public string Name {get; set;}
public string Version {get; set;} public string Version {get; set;}
public string PrivateAssets {get; set;}
} }
} }
} }

View file

@ -82,9 +82,12 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
return this; return this;
} }
public AddItemTransform<T> WithMetadata(string metadataName, Func<T, string> metadataValueFunc) public AddItemTransform<T> WithMetadata(
string metadataName,
Func<T, string> metadataValueFunc,
Func<T, bool> writeMetadataConditionFunc = null)
{ {
_metadata.Add(new ItemMetadataValue<T>(metadataName, metadataValueFunc)); _metadata.Add(new ItemMetadataValue<T>(metadataName, metadataValueFunc, writeMetadataConditionFunc));
return this; return this;
} }
@ -104,7 +107,10 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
foreach (var metadata in _metadata) foreach (var metadata in _metadata)
{ {
item.AddMetadata(metadata.MetadataName, metadata.GetMetadataValue(source)); if (metadata.ShouldWriteMetadata(source))
{
item.AddMetadata(metadata.MetadataName, metadata.GetMetadataValue(source));
}
} }
return item; return item;

View file

@ -28,6 +28,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
} }
else if (typeof(T) == typeof(ProjectPropertyElement)) else if (typeof(T) == typeof(ProjectPropertyElement))
{ {
MigrationTrace.Instance.WriteLine(
$"{nameof(TransformApplicator)}: Adding Property to project {(element as ProjectPropertyElement).Name}");
var property = destinationElement.ContainingProject.CreatePropertyElement("___TEMP___"); var property = destinationElement.ContainingProject.CreatePropertyElement("___TEMP___");
property.CopyFrom(element); property.CopyFrom(element);

View file

@ -14,20 +14,7 @@
"Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000933" "Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000933"
}, },
"frameworks": { "frameworks": {
"net451": { "netstandard1.3": {
"frameworkAssemblies": {
"System.Runtime": {
"type": "build"
},
"System.Collections": {
"type": "build"
},
"System.IO": {
"type": "build"
}
}
},
"netstandard1.6": {
"imports": [ "imports": [
"portable-net45+wp80+win8+wpa81+dnxcore50", "portable-net45+wp80+win8+wpa81+dnxcore50",
"portable-net45+win8" "portable-net45+win8"

View file

@ -544,13 +544,13 @@ namespace Microsoft.DotNet.ProjectModel
return Enumerable.Empty<string>(); return Enumerable.Empty<string>();
} }
if (prop.Type == JTokenType.Array) if (prop.Value.Type == JTokenType.Array)
{ {
return prop.Value<IEnumerable<string>>(); return (prop.Value as JArray).Select(i => i.Value<string>());
} }
else if (prop.Type == JTokenType.String) else if (prop.Value.Type == JTokenType.String)
{ {
return new [] { prop.Value<string>() }; return new [] { prop.Value.ToString() };
} }
return null; return null;
@ -885,7 +885,7 @@ namespace Microsoft.DotNet.ProjectModel
} }
else else
{ {
values = token.Value<string[]>(); values = token.Values<string>();
} }
result = values result = values
.SelectMany(value => value.Split(new[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries)); .SelectMany(value => value.Split(new[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries));

View file

@ -2,7 +2,10 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
#if !NET451 #if !NET451
using System.Runtime.Loader; using System;
using System.IO;
using System.Reflection.Metadata;
using System.Reflection.PortableExecutable;
#endif #endif
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
@ -22,10 +25,42 @@ namespace Microsoft.DotNet.ProjectModel.Utilities
#if NET451 #if NET451
return new NuGetVersion(AssemblyName.GetAssemblyName(path).Version); return new NuGetVersion(AssemblyName.GetAssemblyName(path).Version);
#else #else
return new NuGetVersion(AssemblyLoadContext.GetAssemblyName(path).Version); return new NuGetVersion(GetAssemblyVersionPrivate(path));
#endif #endif
} }
#if !NET451
private static Version GetAssemblyVersionPrivate(string assemblyPath)
{
using (var fileStream = new FileStream(assemblyPath, FileMode.Open, FileAccess.Read, FileShare.Delete | FileShare.Read))
{
return GetAssemblyVersionPrivate(fileStream);
}
}
private static Version GetAssemblyVersionPrivate(Stream assemblyStream)
{
Version result = null;
try
{
using (PEReader peReader = new PEReader(assemblyStream, PEStreamOptions.LeaveOpen))
{
if (peReader.HasMetadata)
{
MetadataReader reader = peReader.GetMetadataReader();
result = reader.GetAssemblyDefinition().Version;
}
}
}
catch (BadImageFormatException)
{
// not a PE
}
return result;
}
#endif
public static string RenderVersion(VersionRange range) public static string RenderVersion(VersionRange range)
{ {
if (range == null) if (range == null)
@ -50,7 +85,7 @@ namespace Microsoft.DotNet.ProjectModel.Utilities
// Work around nuget bug: https://github.com/NuGet/Home/issues/1598 // Work around nuget bug: https://github.com/NuGet/Home/issues/1598
// sb.AppendFormat("{0}-*", range.MinVersion); // sb.AppendFormat("{0}-*", range.MinVersion);
sb.Append($"{range.MinVersion.Version.Major}.{range.MinVersion.Version.Minor}.{range.MinVersion.Version.Build}"); sb.Append($"{range.MinVersion.Version.Major}.{range.MinVersion.Version.Minor}.{range.MinVersion.Version.Build}");
if (string.IsNullOrEmpty(range.MinVersion.Release) || if (string.IsNullOrEmpty(range.MinVersion.Release) ||
string.Equals("-", range.MinVersion.Release)) string.Equals("-", range.MinVersion.Release))
{ {
sb.Append($"-*"); sb.Append($"-*");

View file

@ -15,20 +15,7 @@
"System.Reflection.Metadata": "1.4.1-beta-24410-02" "System.Reflection.Metadata": "1.4.1-beta-24410-02"
}, },
"frameworks": { "frameworks": {
"net451": { "netstandard1.3": {
"frameworkAssemblies": {
"System.Runtime": {
"type": "build"
},
"System.Collections": {
"type": "build"
},
"System.IO": {
"type": "build"
}
}
},
"netstandard1.6": {
"imports": [ "imports": [
"portable-net45+wp80+win8+wpa81+dnxcore50", "portable-net45+wp80+win8+wpa81+dnxcore50",
"dotnet5.4" "dotnet5.4"
@ -36,7 +23,6 @@
"dependencies": { "dependencies": {
"Microsoft.CSharp": "4.0.1", "Microsoft.CSharp": "4.0.1",
"System.Dynamic.Runtime": "4.0.11", "System.Dynamic.Runtime": "4.0.11",
"System.Runtime.Loader": "4.0.0",
"System.Runtime.Serialization.Primitives": "4.1.1", "System.Runtime.Serialization.Primitives": "4.1.1",
"System.Security.Cryptography.Algorithms": "4.2.0", "System.Security.Cryptography.Algorithms": "4.2.0",
"System.Threading.Thread": "4.0.0", "System.Threading.Thread": "4.0.0",

View file

@ -10,12 +10,11 @@
} }
}, },
"frameworks": { "frameworks": {
"netstandard1.6": { "netstandard1.3": {
"imports": [ "imports": [
"portable-net45+wp80+win8+wpa81+dnxcore50" "portable-net45+wp80+win8+wpa81+dnxcore50"
] ]
}, }
"net451": {}
}, },
"packOptions": { "packOptions": {
"projectUrl": "", "projectUrl": "",

View file

@ -3,9 +3,10 @@
using System; using System;
using System.IO; using System.IO;
using System.Linq;
using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.ProjectModel; using Microsoft.DotNet.ProjectModel;
using System.Linq;
using NuGet.Frameworks; using NuGet.Frameworks;
namespace Microsoft.DotNet.Tools.Test namespace Microsoft.DotNet.Tools.Test
@ -27,7 +28,7 @@ namespace Microsoft.DotNet.Tools.Test
var projectPath = GetProjectPath(dotnetTestParams.ProjectOrAssemblyPath); var projectPath = GetProjectPath(dotnetTestParams.ProjectOrAssemblyPath);
var runtimeIdentifiers = !string.IsNullOrEmpty(dotnetTestParams.Runtime) var runtimeIdentifiers = !string.IsNullOrEmpty(dotnetTestParams.Runtime)
? new[] {dotnetTestParams.Runtime} ? new[] {dotnetTestParams.Runtime}
: DotnetRuntimeIdentifiers.InferCurrentRuntimeIdentifiers(); : DotnetRuntimeIdentifiers.InferCurrentRuntimeIdentifiers(DotnetFiles.VersionFileObject);
var exitCode = 0; var exitCode = 0;
// Create a workspace // Create a workspace

View file

@ -5,7 +5,8 @@
"compile": { "compile": {
"include": [ "include": [
"**/*.cs", "**/*.cs",
"../dotnet/CommandLine/*.cs" "../dotnet/CommandLine/*.cs",
"../dotnet/DotnetFiles.cs"
] ]
} }
}, },

View file

@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved. // 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. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Reflection; using System.Reflection;
using System.Reflection.Metadata; using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335; using System.Reflection.Metadata.Ecma335;
@ -9,15 +10,11 @@ namespace Microsoft.Extensions.Testing.Abstractions
{ {
internal static class MetadataExtensions internal static class MetadataExtensions
{ {
private static PropertyInfo s_methodInfoMethodTokenProperty = typeof(MethodInfo).GetProperty("MethodToken");
internal static int GetMethodToken(this MethodInfo methodInfo) internal static int GetMethodToken(this MethodInfo methodInfo)
{ {
#if NETSTANDARD1_3 return (int)s_methodInfoMethodTokenProperty.GetValue(methodInfo);
var methodToken = methodInfo.GetMetadataToken();
#else
var methodToken = methodInfo.MetadataToken;
#endif
return methodToken;
} }
internal static MethodDebugInformationHandle GetMethodDebugInformationHandle(this MethodInfo methodInfo) internal static MethodDebugInformationHandle GetMethodDebugInformationHandle(this MethodInfo methodInfo)

View file

@ -16,8 +16,7 @@
"System.Reflection.Metadata": "1.4.1-beta-24426-02" "System.Reflection.Metadata": "1.4.1-beta-24426-02"
}, },
"frameworks": { "frameworks": {
"net451": {}, "netstandard1.3": {
"netstandard1.6": {
"imports": [ "imports": [
"portable-net45+wp80+win8+wpa81+dnxcore50", "portable-net45+wp80+win8+wpa81+dnxcore50",
"portable-net45+win8" "portable-net45+win8"

View file

@ -1,363 +0,0 @@
// 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;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Compiler.Common;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.ProjectModel.Resolution;
using NuGet.Configuration;
namespace Microsoft.DotNet.Tools.Compiler.Fsc
{
public class CompileFscCommand
{
private const int ExitFailed = 1;
public static int Main(string[] args)
{
DebugHelper.HandleDebugSwitch(ref args);
CommandLineApplication app = new CommandLineApplication();
app.Name = "dotnet compile-fsc";
app.FullName = ".NET F# Compiler";
app.Description = "F# Compiler for the .NET Platform";
app.HandleResponseFiles = true;
app.HelpOption("-h|--help");
CommonCompilerOptionsCommandLine commonCompilerCommandLine = CommonCompilerOptionsCommandLine.AddOptions(app);
AssemblyInfoOptionsCommandLine assemblyInfoCommandLine = AssemblyInfoOptionsCommandLine.AddOptions(app);
CommandOption tempOutputOption = app.Option("--temp-output <arg>", "Compilation temporary directory", CommandOptionType.SingleValue);
CommandOption outputNameOption = app.Option("--out <arg>", "Name of the output assembly", CommandOptionType.SingleValue);
CommandOption referencesOption = app.Option("--reference <arg>...", "Path to a compiler metadata reference", CommandOptionType.MultipleValue);
CommandOption resourcesOption = app.Option("--resource <arg>...", "Resources to embed", CommandOptionType.MultipleValue);
CommandArgument sourcesArgument = app.Argument("<source-files>...", "Compilation sources", multipleValues: true);
app.OnExecute(() =>
{
if (!tempOutputOption.HasValue())
{
Reporter.Error.WriteLine("Option '--temp-output' is required");
return ExitFailed;
}
CommonCompilerOptions commonOptions = commonCompilerCommandLine.GetOptionValues();
AssemblyInfoOptions assemblyInfoOptions = assemblyInfoCommandLine.GetOptionValues();
// TODO less hacky
bool targetNetCore =
commonOptions.Defines.Contains("DNXCORE50") ||
commonOptions.Defines.Where(d => d.StartsWith("NETSTANDARDAPP1_")).Any() ||
commonOptions.Defines.Where(d => d.StartsWith("NETCOREAPP1_")).Any() ||
commonOptions.Defines.Where(d => d.StartsWith("NETSTANDARD1_")).Any();
// Get FSC Path upfront to use it for win32manifest path
string tempOutDir = tempOutputOption.Value();
var fscCommandSpec = ResolveFsc(null, tempOutDir);
var fscExeFile = fscCommandSpec.FscExeFile;
var fscExeDir = fscCommandSpec.FscExeDir;
// FSC arguments
var allArgs = new List<string>();
//HACK fsc raise error FS0208 if target exe doesnt have extension .exe
bool hackFS0208 = targetNetCore && commonOptions.EmitEntryPoint == true;
string outputName = outputNameOption.Value();
var originalOutputName = outputName;
if (outputName != null)
{
if (hackFS0208)
{
outputName = Path.ChangeExtension(outputName, ".exe");
}
allArgs.Add($"--out:{outputName}");
}
//let's pass debugging type only if options.DebugType is specified, until
//portablepdb are confirmed to work.
//so it's possibile to test portable pdb without breaking existing build
if (string.IsNullOrEmpty(commonOptions.DebugType))
{
//debug info (only windows pdb supported, not portablepdb)
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
allArgs.Add("--debug");
//TODO check if full or pdbonly
allArgs.Add("--debug:pdbonly");
}
else
allArgs.Add("--debug-");
}
else
{
allArgs.Add("--debug");
allArgs.Add($"--debug:{commonOptions.DebugType}");
}
// Default options
allArgs.Add("--noframework");
allArgs.Add("--nologo");
allArgs.Add("--simpleresolution");
allArgs.Add("--nocopyfsharpcore");
// project.json compilationOptions
if (commonOptions.Defines != null)
{
allArgs.AddRange(commonOptions.Defines.Select(def => $"--define:{def}"));
}
if (commonOptions.GenerateXmlDocumentation == true)
{
allArgs.Add($"--doc:{Path.ChangeExtension(outputName, "xml")}");
}
if (commonOptions.KeyFile != null)
{
allArgs.Add($"--keyfile:{commonOptions.KeyFile}");
}
if (commonOptions.Optimize == true)
{
allArgs.Add("--optimize+");
}
//--resource doesnt expect "
//bad: --resource:"path/to/file",name
//ok: --resource:path/to/file,name
allArgs.AddRange(resourcesOption.Values.Select(resource => $"--resource:{resource.Replace("\"", "")}"));
allArgs.AddRange(referencesOption.Values.Select(r => $"-r:{r}"));
if (commonOptions.EmitEntryPoint != true)
{
allArgs.Add("--target:library");
}
else
{
allArgs.Add("--target:exe");
//HACK we need default.win32manifest for exe
var win32manifestPath = Path.Combine(fscExeDir, "..", "..", "runtimes", "any", "native", "default.win32manifest");
allArgs.Add($"--win32manifest:{win32manifestPath}");
}
if (commonOptions.SuppressWarnings != null && commonOptions.SuppressWarnings.Any())
{
allArgs.Add("--nowarn:" + string.Join(",", commonOptions.SuppressWarnings.ToArray()));
}
if (commonOptions.LanguageVersion != null)
{
// Not used in fsc
}
if (commonOptions.Platform != null)
{
allArgs.Add($"--platform:{commonOptions.Platform}");
}
if (commonOptions.AllowUnsafe == true)
{
}
if (commonOptions.WarningsAsErrors == true)
{
allArgs.Add("--warnaserror");
}
//set target framework
if (targetNetCore)
{
allArgs.Add("--targetprofile:netcore");
}
if (commonOptions.DelaySign == true)
{
allArgs.Add("--delaysign+");
}
if (commonOptions.PublicSign == true)
{
}
if (commonOptions.AdditionalArguments != null)
{
// Additional arguments are added verbatim
allArgs.AddRange(commonOptions.AdditionalArguments);
}
// Generate assembly info
var assemblyInfo = Path.Combine(tempOutDir, $"dotnet-compile.assemblyinfo.fs");
File.WriteAllText(assemblyInfo, AssemblyInfoFileGenerator.GenerateFSharp(assemblyInfoOptions));
//source files + assemblyInfo
allArgs.AddRange(GetSourceFiles(sourcesArgument.Values, assemblyInfo).ToArray());
//TODO check the switch enabled in fsproj in RELEASE and DEBUG configuration
var rsp = Path.Combine(tempOutDir, "dotnet-compile-fsc.rsp");
File.WriteAllLines(rsp, allArgs, Encoding.UTF8);
// Execute FSC!
var result = RunFsc(new List<string> { $"@{rsp}" }, tempOutDir)
.ForwardStdErr()
.ForwardStdOut()
.Execute();
bool successFsc = result.ExitCode == 0;
if (hackFS0208 && File.Exists(outputName))
{
if (File.Exists(originalOutputName))
File.Delete(originalOutputName);
File.Move(outputName, originalOutputName);
}
//HACK dotnet build require a pdb (crash without), fsc atm cant generate a portable pdb, so an empty pdb is created
string pdbPath = Path.ChangeExtension(outputName, ".pdb");
if (successFsc && !File.Exists(pdbPath))
{
File.WriteAllBytes(pdbPath, Array.Empty<byte>());
}
return result.ExitCode;
});
try
{
return app.Execute(args);
}
catch (Exception ex)
{
#if DEBUG
Reporter.Error.WriteLine(ex.ToString());
#else
Reporter.Error.WriteLine(ex.Message);
#endif
return ExitFailed;
}
}
// The assembly info must be in the last minus 1 position because:
// - assemblyInfo should be in the end to override attributes
// - assemblyInfo cannot be in the last position, because last file contains the main
private static IEnumerable<string> GetSourceFiles(IReadOnlyList<string> sourceFiles, string assemblyInfo)
{
if (!sourceFiles.Any())
{
yield return assemblyInfo;
yield break;
}
foreach (var s in sourceFiles.Take(sourceFiles.Count() - 1))
yield return s;
yield return assemblyInfo;
yield return sourceFiles.Last();
}
private static Command RunFsc(List<string> fscArgs, string temp)
{
var fscEnvExe = Environment.GetEnvironmentVariable("DOTNET_FSC_PATH");
var exec = Environment.GetEnvironmentVariable("DOTNET_FSC_EXEC")?.ToUpper() ?? "COREHOST";
var muxer = new Muxer();
if (fscEnvExe != null)
{
switch (exec)
{
case "RUN":
return Command.Create(fscEnvExe, fscArgs.ToArray());
case "COREHOST":
default:
var host = muxer.MuxerPath;
return Command.Create(host, new[] { fscEnvExe }.Concat(fscArgs).ToArray());
}
}
else
{
var fscCommandSpec = ResolveFsc(fscArgs, temp)?.Spec;
return Command.Create(fscCommandSpec);
}
}
private static FscCommandSpec ResolveFsc(List<string> fscArgs, string temp)
{
var nugetPackagesRoot = NuGetPathContext.Create(Directory.GetCurrentDirectory())?.UserPackageFolder;
var depsFile = Path.Combine(AppContext.BaseDirectory, "dotnet-compile-fsc" + FileNameSuffixes.DepsJson);
var depsJsonCommandResolver = new DepsJsonCommandResolver(nugetPackagesRoot);
var dependencyContext = depsJsonCommandResolver.LoadDependencyContextFromFile(depsFile);
var fscPath = depsJsonCommandResolver.GetCommandPathFromDependencyContext("fsc", dependencyContext);
var commandResolverArgs = new CommandResolverArguments()
{
CommandName = "fsc",
CommandArguments = fscArgs,
DepsJsonFile = depsFile
};
var fscCommandSpec = depsJsonCommandResolver.Resolve(commandResolverArgs);
var runtimeConfigFile = Path.Combine(
Path.GetDirectoryName(typeof(CompileFscCommand).GetTypeInfo().Assembly.Location)
, "dotnet-compile-fsc" + FileNameSuffixes.RuntimeConfigJson);
CopyRuntimeConfigForFscExe(runtimeConfigFile, "fsc", depsFile, nugetPackagesRoot, fscPath);
return new FscCommandSpec
{
Spec = fscCommandSpec,
FscExeDir = Path.GetDirectoryName(fscPath),
FscExeFile = fscPath
};
}
private static void CopyRuntimeConfigForFscExe(
string runtimeConfigFile,
string commandName,
string depsJsonFile,
string nugetPackagesRoot,
string fscPath)
{
var newFscRuntimeConfigDir = Path.GetDirectoryName(fscPath);
var newFscRuntimeConfigFile = Path.Combine(
newFscRuntimeConfigDir,
Path.GetFileNameWithoutExtension(fscPath) + FileNameSuffixes.RuntimeConfigJson);
try
{
File.Copy(runtimeConfigFile, newFscRuntimeConfigFile, true);
}
catch(Exception e)
{
Reporter.Error.WriteLine("Failed to copy fsc runtimeconfig.json");
throw e;
}
}
private class FscCommandSpec
{
public CommandSpec Spec { get; set; }
public string FscExeDir { get; set; }
public string FscExeFile { get; set; }
}
}
}

View file

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>60cf7e6c-d6c8-439d-b7b7-d8a27e29be2c</ProjectGuid>
<RootNamespace>Microsoft.DotNet.Tools.Compiler.Fsc</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View file

@ -1,39 +0,0 @@
{
"version": "1.0.0-preview3-*",
"buildOptions": {
"emitEntryPoint": true,
"compile": {
"include": [
"**/*.cs",
"../dotnet/CommandLine/*.cs",
"../dotnet/commands/dotnet-compile-csc/AssemblyInfoOptionsCommandLine.cs",
"../dotnet/commands/dotnet-compile-csc/CommonCompilerOptionsCommandLine.cs"
]
}
},
"dependencies": {
"Microsoft.FSharp.Compiler.netcore": "1.0.0-alpha-160509",
"Microsoft.DotNet.ProjectModel": {
"target": "project"
},
"Microsoft.DotNet.Compiler.Common": {
"target": "project"
},
"Microsoft.DotNet.Cli.Utils": {
"target": "project"
},
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dnxcore50",
"portable-net45+win81",
"netstandard1.3"
]
}
}
}

View file

@ -45,6 +45,7 @@ namespace Microsoft.DotNet.Cli.CommandLine
public List<CommandLineApplication> Commands { get; private set; } public List<CommandLineApplication> Commands { get; private set; }
public bool HandleResponseFiles { get; set; } public bool HandleResponseFiles { get; set; }
public bool AllowArgumentSeparator { get; set; } public bool AllowArgumentSeparator { get; set; }
public string ArgumentSeparatorHelpText { get; set; }
public CommandLineApplication Command(string name, Action<CommandLineApplication> configuration, public CommandLineApplication Command(string name, Action<CommandLineApplication> configuration,
bool throwOnUnexpectedArg = true) bool throwOnUnexpectedArg = true)
@ -361,6 +362,7 @@ namespace Microsoft.DotNet.Cli.CommandLine
var optionsBuilder = new StringBuilder(); var optionsBuilder = new StringBuilder();
var commandsBuilder = new StringBuilder(); var commandsBuilder = new StringBuilder();
var argumentsBuilder = new StringBuilder(); var argumentsBuilder = new StringBuilder();
var argumentSeparatorBuilder = new StringBuilder();
if (target.Arguments.Any()) if (target.Arguments.Any())
{ {
@ -417,6 +419,13 @@ namespace Microsoft.DotNet.Cli.CommandLine
if (target.AllowArgumentSeparator) if (target.AllowArgumentSeparator)
{ {
headerBuilder.Append(" [[--] <arg>...]]"); headerBuilder.Append(" [[--] <arg>...]]");
if (!string.IsNullOrEmpty(target.ArgumentSeparatorHelpText))
{
argumentSeparatorBuilder.AppendLine();
argumentSeparatorBuilder.AppendLine("Args:");
argumentSeparatorBuilder.AppendLine($" {target.ArgumentSeparatorHelpText}");
argumentSeparatorBuilder.AppendLine();
}
} }
headerBuilder.AppendLine(); headerBuilder.AppendLine();
@ -425,7 +434,7 @@ namespace Microsoft.DotNet.Cli.CommandLine
nameAndVersion.AppendLine(GetFullNameAndVersion()); nameAndVersion.AppendLine(GetFullNameAndVersion());
nameAndVersion.AppendLine(); nameAndVersion.AppendLine();
Console.Write("{0}{1}{2}{3}{4}", nameAndVersion, headerBuilder, argumentsBuilder, optionsBuilder, commandsBuilder); Console.Write("{0}{1}{2}{3}{4}{5}", nameAndVersion, headerBuilder, argumentsBuilder, optionsBuilder, commandsBuilder, argumentSeparatorBuilder);
} }
public void ShowVersion() public void ShowVersion()

View file

@ -0,0 +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.
namespace Microsoft.DotNet.Cli.CommandLine
{
internal class HelpMessageStrings
{
internal const string MSBuildAdditionalArgsHelpText = "Any extra options that should be passed to MSBuild. See 'dotnet msbuild -h' for available options.";
}
}

View file

@ -4,11 +4,12 @@
using System; using System;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.PlatformAbstractions; using Microsoft.DotNet.PlatformAbstractions;
namespace Microsoft.DotNet.Cli.Utils namespace Microsoft.DotNet.Cli
{ {
public static class DotnetFiles internal static class DotnetFiles
{ {
private static string SdkRootFolder => Path.Combine(typeof(DotnetFiles).GetTypeInfo().Assembly.Location, ".."); private static string SdkRootFolder => Path.Combine(typeof(DotnetFiles).GetTypeInfo().Assembly.Location, "..");
@ -25,9 +26,6 @@ namespace Microsoft.DotNet.Cli.Utils
get { return s_versionFileObject.Value; } get { return s_versionFileObject.Value; }
} }
public static string NuGetPackagesArchive =>
Path.GetFullPath(Path.Combine(SdkRootFolder, "nuGetPackagesArchive.lzma"));
/// <summary> /// <summary>
/// Reads the version file and adds runtime specific information /// Reads the version file and adds runtime specific information
/// </summary> /// </summary>

View file

@ -13,6 +13,7 @@ using Microsoft.DotNet.PlatformAbstractions;
using Microsoft.DotNet.ProjectModel.Server; using Microsoft.DotNet.ProjectModel.Server;
using Microsoft.DotNet.Tools.Build; using Microsoft.DotNet.Tools.Build;
using Microsoft.DotNet.Tools.Build3; using Microsoft.DotNet.Tools.Build3;
using Microsoft.DotNet.Tools.Clean3;
using Microsoft.DotNet.Tools.Compiler; using Microsoft.DotNet.Tools.Compiler;
using Microsoft.DotNet.Tools.Compiler.Csc; using Microsoft.DotNet.Tools.Compiler.Csc;
using Microsoft.DotNet.Tools.Help; using Microsoft.DotNet.Tools.Help;
@ -48,6 +49,7 @@ namespace Microsoft.DotNet.Cli
["run"] = RunCommand.Run, ["run"] = RunCommand.Run,
["test"] = TestCommand.Run, ["test"] = TestCommand.Run,
["build3"] = Build3Command.Run, ["build3"] = Build3Command.Run,
["clean3"] = Clean3Command.Run,
["msbuild"] = MSBuildCommand.Run, ["msbuild"] = MSBuildCommand.Run,
["run3"] = Run3Command.Run, ["run3"] = Run3Command.Run,
["restore3"] = Restore3Command.Run, ["restore3"] = Restore3Command.Run,

View file

@ -2,6 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.CommandLine; using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.InternalAbstractions; using Microsoft.DotNet.InternalAbstractions;
@ -131,7 +132,7 @@ namespace Microsoft.DotNet.Tools.Compiler
var rids = new List<string>(); var rids = new List<string>();
if (string.IsNullOrEmpty(RuntimeValue)) if (string.IsNullOrEmpty(RuntimeValue))
{ {
return DotnetRuntimeIdentifiers.InferCurrentRuntimeIdentifiers(); return DotnetRuntimeIdentifiers.InferCurrentRuntimeIdentifiers(DotnetFiles.VersionFileObject);
} }
else else
{ {

View file

@ -5,8 +5,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.Compiler.Common; using Microsoft.DotNet.Cli.Compiler.Common;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.Compiler; using Microsoft.DotNet.Tools.Compiler;
namespace Microsoft.DotNet.Tools.Build namespace Microsoft.DotNet.Tools.Build

View file

@ -19,6 +19,7 @@ namespace Microsoft.DotNet.Tools.Build3
app.FullName = ".NET Builder"; app.FullName = ".NET Builder";
app.Description = "Builder for the .NET Platform. Delegates to the MSBuild 'Build' target in the project file."; app.Description = "Builder for the .NET Platform. Delegates to the MSBuild 'Build' target in the project file.";
app.AllowArgumentSeparator = true; app.AllowArgumentSeparator = true;
app.ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText;
app.HelpOption("-h|--help"); app.HelpOption("-h|--help");
CommandArgument projectArgument = app.Argument("<PROJECT>", CommandArgument projectArgument = app.Argument("<PROJECT>",

View file

@ -0,0 +1,69 @@
// 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 Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.MSBuild;
namespace Microsoft.DotNet.Tools.Clean3
{
public class Clean3Command
{
public static int Run(string[] args)
{
DebugHelper.HandleDebugSwitch(ref args);
CommandLineApplication app = new CommandLineApplication(throwOnUnexpectedArg: false)
{
Name = "dotnet clean3",
FullName = ".NET Clean Command",
Description = "Command to clean previously generated build outputs.",
AllowArgumentSeparator = true,
ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText
};
app.HelpOption("-h|--help");
CommandArgument projectArgument = app.Argument("<PROJECT>",
"The MSBuild project file to build. If a project file is not specified," +
" MSBuild searches the current working directory for a file that has a file extension that ends in `proj` and uses that file.");
CommandOption outputOption = app.Option("-o|--output <OUTPUT_DIR>", "Directory in which the build outputs have been placed", CommandOptionType.SingleValue);
CommandOption frameworkOption = app.Option("-f|--framework <FRAMEWORK>", "Clean a specific framework", CommandOptionType.SingleValue);
CommandOption configurationOption = app.Option("-c|--configuration <CONFIGURATION>", "Clean a specific configuration", CommandOptionType.SingleValue);
app.OnExecute(() =>
{
List<string> msbuildArgs = new List<string>();
if (!string.IsNullOrEmpty(projectArgument.Value))
{
msbuildArgs.Add(projectArgument.Value);
}
msbuildArgs.Add("/t:Clean");
if (outputOption.HasValue())
{
msbuildArgs.Add($"/p:OutputPath={outputOption.Value()}");
}
if (frameworkOption.HasValue())
{
msbuildArgs.Add($"/p:TargetFramework={frameworkOption.Value()}");
}
if (configurationOption.HasValue())
{
msbuildArgs.Add($"/p:Configuration={configurationOption.Value()}");
}
msbuildArgs.AddRange(app.RemainingArguments);
return new MSBuildForwardingApp(msbuildArgs).Execute();
});
return app.Execute(args);
}
}
}

View file

@ -195,21 +195,24 @@ namespace Microsoft.DotNet.Tools.Migrate
else if (projectArg.EndsWith(GlobalSettings.FileName, StringComparison.OrdinalIgnoreCase)) else if (projectArg.EndsWith(GlobalSettings.FileName, StringComparison.OrdinalIgnoreCase))
{ {
projects = GetProjectsFromGlobalJson(projectArg); projects = GetProjectsFromGlobalJson(projectArg);
if (!projects.Any())
{
throw new Exception("Unable to find any projects in global.json");
}
} }
else if (Directory.Exists(projectArg)) else if (Directory.Exists(projectArg))
{ {
projects = Directory.EnumerateFiles(projectArg, Project.FileName, SearchOption.AllDirectories); projects = Directory.EnumerateFiles(projectArg, Project.FileName, SearchOption.AllDirectories);
if (!projects.Any())
{
throw new Exception($"No project.json file found in '{projectArg}'");
}
} }
else else
{ {
throw new Exception($"Invalid project argument - '{projectArg}' is not a project.json or a global.json file and a directory named '{projectArg}' doesn't exist."); throw new Exception($"Invalid project argument - '{projectArg}' is not a project.json or a global.json file and a directory named '{projectArg}' doesn't exist.");
} }
if (!projects.Any())
{
throw new Exception($"Invalid project argument - Unable to find any projects in global.json or directory '{projectArg}'");
}
foreach(var project in projects) foreach(var project in projects)
{ {
yield return GetProjectJsonPath(project); yield return GetProjectJsonPath(project);

View file

@ -69,6 +69,7 @@ namespace Microsoft.DotNet.Tools.Migrate
#else #else
Reporter.Error.WriteLine(ex.Message); Reporter.Error.WriteLine(ex.Message);
#endif #endif
Reporter.Error.WriteLine("Migration failed.");
return 1; return 1;
} }
} }

View file

@ -16,8 +16,9 @@
<PackageReference Include="Microsoft.NETCore.App"> <PackageReference Include="Microsoft.NETCore.App">
<Version>1.0.1</Version> <Version>1.0.1</Version>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.NETCore.Sdk"> <PackageReference Include="Microsoft.NET.Sdk">
<Version>1.0.0-alpha-20161007-1</Version> <Version>1.0.0-alpha-20161010-1</Version>
<PrivateAssets>All</PrivateAssets>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>

View file

@ -18,7 +18,9 @@ namespace Microsoft.DotNet.Tools.Pack3
{ {
Name = "pack3", Name = "pack3",
FullName = "pack3", FullName = "pack3",
Description = "pack for msbuild" Description = "pack for msbuild",
AllowArgumentSeparator = true,
ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText
}; };
cmd.HelpOption("-h|--help"); cmd.HelpOption("-h|--help");

View file

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.Compiler.Common; using Microsoft.DotNet.Cli.Compiler.Common;
using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Files; using Microsoft.DotNet.Files;
@ -414,7 +415,7 @@ namespace Microsoft.DotNet.Tools.Publish
contexts.Where(c => Equals(c.TargetFramework, framework)); contexts.Where(c => Equals(c.TargetFramework, framework));
var rids = string.IsNullOrEmpty(runtime) ? var rids = string.IsNullOrEmpty(runtime) ?
DotnetRuntimeIdentifiers.InferCurrentRuntimeIdentifiers() : DotnetRuntimeIdentifiers.InferCurrentRuntimeIdentifiers(DotnetFiles.VersionFileObject) :
new[] { runtime }; new[] { runtime };
return contexts.Select(c => Workspace.GetRuntimeContext(c, rids)); return contexts.Select(c => Workspace.GetRuntimeContext(c, rids));

View file

@ -17,6 +17,7 @@ namespace Microsoft.DotNet.Tools.Publish3
app.FullName = ".NET Publisher"; app.FullName = ".NET Publisher";
app.Description = "Publisher for the .NET Platform"; app.Description = "Publisher for the .NET Platform";
app.AllowArgumentSeparator = true; app.AllowArgumentSeparator = true;
app.ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText;
app.HelpOption("-h|--help"); app.HelpOption("-h|--help");
CommandArgument projectArgument = app.Argument("<PROJECT>", CommandArgument projectArgument = app.Argument("<PROJECT>",

View file

@ -18,7 +18,9 @@ namespace Microsoft.DotNet.Tools.Restore3
{ {
Name = "restore3", Name = "restore3",
FullName = "restore3", FullName = "restore3",
Description = "restore for msbuild" Description = "restore for msbuild",
AllowArgumentSeparator = true,
ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText
}; };
cmd.HelpOption("-h|--help"); cmd.HelpOption("-h|--help");

View file

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.InternalAbstractions; using Microsoft.DotNet.InternalAbstractions;
using Microsoft.DotNet.ProjectModel; using Microsoft.DotNet.ProjectModel;
@ -83,7 +84,7 @@ namespace Microsoft.DotNet.Tools.Run
.EnsureValid(Project) .EnsureValid(Project)
.FrameworkOnlyContexts; .FrameworkOnlyContexts;
var rids = DotnetRuntimeIdentifiers.InferCurrentRuntimeIdentifiers(); var rids = DotnetRuntimeIdentifiers.InferCurrentRuntimeIdentifiers(DotnetFiles.VersionFileObject);
ProjectContext frameworkContext; ProjectContext frameworkContext;
if (Framework == null) if (Framework == null)

View file

@ -19,6 +19,7 @@ namespace Microsoft.DotNet.Tools.Run
app.Description = "Command used to run .NET apps"; app.Description = "Command used to run .NET apps";
app.HandleResponseFiles = true; app.HandleResponseFiles = true;
app.AllowArgumentSeparator = true; app.AllowArgumentSeparator = true;
app.ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText;
app.HelpOption("-h|--help"); app.HelpOption("-h|--help");
CommandOption configuration = app.Option( CommandOption configuration = app.Option(

View file

@ -69,7 +69,7 @@
"exclude": "compile" "exclude": "compile"
}, },
"Microsoft.Build": "15.1.298-preview5", "Microsoft.Build": "15.1.316-preview5",
"Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000933" "Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000933"
}, },

View file

@ -19,7 +19,7 @@
"tool_nuget": "1.0.0-preview3-*", "tool_nuget": "1.0.0-preview3-*",
"tool_msbuild": "1.0.0-preview3-*", "tool_msbuild": "1.0.0-preview3-*",
"Microsoft.Build.Runtime": "15.1.298-preview5", "Microsoft.Build.Runtime": "15.1.316-preview5",
"Microsoft.CodeAnalysis.Build.Tasks": "2.0.0-beta6-60922-08", "Microsoft.CodeAnalysis.Build.Tasks": "2.0.0-beta6-60922-08",
"System.Runtime.Serialization.Xml": "4.1.1", "System.Runtime.Serialization.Xml": "4.1.1",
"NuGet.Build.Tasks": "3.6.0-rc-1954", "NuGet.Build.Tasks": "3.6.0-rc-1954",

View file

@ -8,7 +8,7 @@
"type": "platform", "type": "platform",
"version": "1.0.1" "version": "1.0.1"
}, },
"Microsoft.Build.Runtime": "15.1.298-preview5", "Microsoft.Build.Runtime": "15.1.316-preview5",
"Microsoft.Net.Compilers.netcore": "2.0.0-beta6-60922-08", "Microsoft.Net.Compilers.netcore": "2.0.0-beta6-60922-08",
"Microsoft.CodeAnalysis.Build.Tasks": "2.0.0-beta6-60922-08", "Microsoft.CodeAnalysis.Build.Tasks": "2.0.0-beta6-60922-08",
"Microsoft.Cci": "4.0.0-rc3-24128-00", "Microsoft.Cci": "4.0.0-rc3-24128-00",

View file

@ -196,7 +196,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd
TestProject = Path.Combine(TestDirectory, "project.json"); TestProject = Path.Combine(TestDirectory, "project.json");
OutputDirectory = Path.Combine(TestDirectory, s_outputdirName); OutputDirectory = Path.Combine(TestDirectory, s_outputdirName);
Rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier(); Rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
} }
private static void SetupStaticTestProject() private static void SetupStaticTestProject()

View file

@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved. // 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. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.IO;
using Microsoft.DotNet.Tools.Test.Utilities; using Microsoft.DotNet.Tools.Test.Utilities;
using Xunit; using Xunit;
@ -9,7 +10,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd
public class GivenDotNetUsesMSBuild : TestBase public class GivenDotNetUsesMSBuild : TestBase
{ {
[Fact] [Fact]
public void ItCanNewRestoreBuildRunMSBuildProject() public void ItCanNewRestoreBuildRunCleanMSBuildProject()
{ {
using (DisposableDirectory directory = Temp.CreateDirectory()) using (DisposableDirectory directory = Temp.CreateDirectory())
{ {
@ -41,6 +42,17 @@ namespace Microsoft.DotNet.Tests.EndToEnd
.Pass() .Pass()
.And .And
.HaveStdOutContaining("Hello World!"); .HaveStdOutContaining("Hello World!");
var binDirectory = new DirectoryInfo(projectDirectory).Sub("bin");
binDirectory.Should().HaveFilesMatching("*.dll", SearchOption.AllDirectories);
new Clean3Command()
.WithWorkingDirectory(projectDirectory)
.Execute()
.Should()
.Pass();
binDirectory.Should().NotHaveFilesMatching("*.dll", SearchOption.AllDirectories);
} }
} }

View file

@ -1,35 +0,0 @@
// 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;
using System.IO;
using Microsoft.DotNet.Tools.Test.Utilities;
using FluentAssertions;
namespace Microsoft.DotNet.Cli.Utils.Tests
{
public class GivenADesktopAppWhichUsesCommandCreateDotnet : TestBase
{
[WindowsOnlyFact]
public void It_calls_dotnet_build_on_a_project_successfully()
{
var testAssetsManager = GetTestGroupTestAssetsManager("DesktopTestProjects");
var testInstance = testAssetsManager
.CreateTestInstance("DesktopAppWhichCallsDotnet")
.WithLockFiles()
.WithBuildArtifacts();
// project was moved to another location and needs it's relative path to Utils project restored
new RestoreCommand().Execute(testInstance.TestRoot).Should().Pass();
var testProjectAssetManager = GetTestGroupTestAssetsManager("TestProjects");
var testInstanceToBuild = testProjectAssetManager
.CreateTestInstance("TestAppSimple")
.WithLockFiles();
var testProject = Path.Combine(testInstance.TestRoot, "project.json");
var testProjectToBuild = Path.Combine(testInstanceToBuild.TestRoot, "project.json");
new RunCommand(testProject).Execute(testProjectToBuild).Should().Pass();
}
}
}

View file

@ -4,6 +4,8 @@
using System; using System;
using System.IO; using System.IO;
using FluentAssertions; using FluentAssertions;
using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.InternalAbstractions; using Microsoft.DotNet.InternalAbstractions;
using Microsoft.DotNet.ProjectModel; using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.Tools.Test.Utilities; using Microsoft.DotNet.Tools.Test.Utilities;
@ -227,8 +229,8 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
var projectContext = ProjectContext.Create( var projectContext = ProjectContext.Create(
testInstance.Path, testInstance.Path,
FrameworkConstants.CommonFrameworks.NetCoreApp10, FrameworkConstants.CommonFrameworks.NetCoreApp10,
RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers()); DotnetRuntimeIdentifiers.InferCurrentRuntimeIdentifiers(DotnetFiles.VersionFileObject));
var depsFilePath = var depsFilePath =
projectContext.GetOutputPaths("Debug", outputPath: outputDir).RuntimeFiles.DepsJson; projectContext.GetOutputPaths("Debug", outputPath: outputDir).RuntimeFiles.DepsJson;
@ -267,7 +269,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
var projectContext = ProjectContext.Create( var projectContext = ProjectContext.Create(
testInstance.Path, testInstance.Path,
FrameworkConstants.CommonFrameworks.NetCoreApp10, FrameworkConstants.CommonFrameworks.NetCoreApp10,
RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers()); DotnetRuntimeIdentifiers.InferCurrentRuntimeIdentifiers(DotnetFiles.VersionFileObject));
var depsFilePath = var depsFilePath =
projectContext.GetOutputPaths("Debug", buildBasePath).RuntimeFiles.DepsJson; projectContext.GetOutputPaths("Debug", buildBasePath).RuntimeFiles.DepsJson;

View file

@ -13,7 +13,7 @@ namespace StreamForwarderTests
{ {
public class StreamForwarderTests : TestBase public class StreamForwarderTests : TestBase
{ {
private static readonly string s_rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier(); private static readonly string s_rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
public static void Main() public static void Main()
{ {

View file

@ -3,14 +3,24 @@
"buildOptions": { "buildOptions": {
"emitEntryPoint": true, "emitEntryPoint": true,
"keyFile": "../../tools/Key.snk", "keyFile": "../../tools/Key.snk",
"compile": {
"include": [
"**/*.cs",
"../../src/dotnet/DotnetFiles.cs"
]
},
"copyToOutput": { "copyToOutput": {
"include": [ "include": [
"../../TestAssets/TestProjects/OutputStandardOutputAndError/*", "../../TestAssets/TestProjects/OutputStandardOutputAndError/*",
"../../TestAssets/TestProjects/TestAppWithArgs/*", "../../TestAssets/TestProjects/TestAppWithArgs/*",
"../../TestAssets/TestProjects/AppWithDirectAndToolDependency/**/*", "../../TestAssets/TestProjects/AppWithDirectAndToolDependency/**/*",
"../../TestAssets/TestProjects/AppWithDirectDependency/**/*", "../../TestAssets/TestProjects/AppWithDirectDependency/**/*",
"../../TestAssets/TestProjects/AppWithToolDependency/**/*" "../../TestAssets/TestProjects/AppWithToolDependency/**/*",
] "../../artifacts/*/stage2/sdk/*/.version"
],
"mappings": {
".version": "../../artifacts/*/stage2/sdk/*/.version"
}
} }
}, },
"dependencies": { "dependencies": {

View file

@ -6,6 +6,7 @@ using Microsoft.DotNet.Tools.Test.Utilities;
using System.Linq; using System.Linq;
using Xunit; using Xunit;
using FluentAssertions; using FluentAssertions;
using Microsoft.DotNet.ProjectJsonMigration;
using Microsoft.DotNet.ProjectJsonMigration.Rules; using Microsoft.DotNet.ProjectJsonMigration.Rules;
using System; using System;
@ -27,6 +28,126 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
EmitsPackageReferences(mockProj, Tuple.Create("APackage", "1.0.0-preview", ""), Tuple.Create("BPackage", "1.0.0", "")); EmitsPackageReferences(mockProj, Tuple.Create("APackage", "1.0.0-preview", ""), Tuple.Create("BPackage", "1.0.0", ""));
} }
[Fact]
public void It_migrates_type_build_to_PrivateAssets()
{
var mockProj = RunPackageDependenciesRuleOnPj(@"
{
""dependencies"": {
""APackage"" : {
""version"": ""1.0.0-preview"",
""type"": ""build""
}
}
}");
var packageRef = mockProj.Items.First(i => i.Include == "APackage" && i.ItemType == "PackageReference");
var privateAssetsMetadata = packageRef.GetMetadataWithName("PrivateAssets");
privateAssetsMetadata.Value.Should().NotBeNull();
privateAssetsMetadata.Value.Should().Be("All");
}
[Fact]
public void It_migrates_suppress_parent_array_to_PrivateAssets()
{
var mockProj = RunPackageDependenciesRuleOnPj(@"
{
""dependencies"": {
""APackage"" : {
""version"": ""1.0.0-preview"",
""suppressParent"":[ ""runtime"", ""native"" ]
}
}
}");
var packageRef = mockProj.Items.First(i => i.Include == "APackage" && i.ItemType == "PackageReference");
var privateAssetsMetadata = packageRef.GetMetadataWithName("PrivateAssets");
privateAssetsMetadata.Value.Should().NotBeNull();
privateAssetsMetadata.Value.Should().Be("Native;Runtime");
}
[Fact]
public void It_migrates_suppress_parent_string_to_PrivateAssets()
{
var mockProj = RunPackageDependenciesRuleOnPj(@"
{
""dependencies"": {
""APackage"" : {
""version"": ""1.0.0-preview"",
""suppressParent"":""runtime""
}
}
}");
var packageRef = mockProj.Items.First(i => i.Include == "APackage" && i.ItemType == "PackageReference");
var privateAssetsMetadata = packageRef.GetMetadataWithName("PrivateAssets");
privateAssetsMetadata.Value.Should().NotBeNull();
privateAssetsMetadata.Value.Should().Be("Runtime");
}
[Fact]
public void It_migrates_include_exclude_arrays_to_IncludeAssets()
{
var mockProj = RunPackageDependenciesRuleOnPj(@"
{
""dependencies"": {
""APackage"" : {
""version"": ""1.0.0-preview"",
""include"": [ ""compile"", ""runtime"", ""native"" ],
""exclude"": [ ""native"" ]
}
}
}");
var packageRef = mockProj.Items.First(i => i.Include == "APackage" && i.ItemType == "PackageReference");
var includeAssetsMetadata = packageRef.GetMetadataWithName("IncludeAssets");
includeAssetsMetadata.Value.Should().NotBeNull();
includeAssetsMetadata.Value.Should().Be("Compile;Runtime");
}
[Fact]
public void It_migrates_include_string_to_IncludeAssets()
{
var mockProj = RunPackageDependenciesRuleOnPj(@"
{
""dependencies"": {
""APackage"" : {
""version"": ""1.0.0-preview"",
""include"": ""compile"",
""exclude"": ""runtime""
}
}
}");
var packageRef = mockProj.Items.First(i => i.Include == "APackage" && i.ItemType == "PackageReference");
var includeAssetsMetadata = packageRef.GetMetadataWithName("IncludeAssets");
includeAssetsMetadata.Value.Should().NotBeNull();
includeAssetsMetadata.Value.Should().Be("Compile");
}
[Fact]
public void It_migrates_include_exclude_overlapping_strings_to_IncludeAssets()
{
var mockProj = RunPackageDependenciesRuleOnPj(@"
{
""dependencies"": {
""APackage"" : {
""version"": ""1.0.0-preview"",
""include"": ""compile"",
""exclude"": ""compile"",
}
}
}");
var packageRef = mockProj.Items.First(i => i.Include == "APackage" && i.ItemType == "PackageReference");
var includeAssetsMetadata = packageRef.GetMetadataWithName("IncludeAssets");
includeAssetsMetadata.Value.Should().NotBeNull();
includeAssetsMetadata.Value.Should().Be("None");
}
[Fact] [Fact]
public void It_migrates_Tools() public void It_migrates_Tools()
{ {
@ -41,6 +162,44 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
EmitsToolReferences(mockProj, Tuple.Create("APackage", "1.0.0-preview"), Tuple.Create("BPackage", "1.0.0")); EmitsToolReferences(mockProj, Tuple.Create("APackage", "1.0.0-preview"), Tuple.Create("BPackage", "1.0.0"));
} }
[Fact]
public void It_migrates_imports_per_framework()
{
var importPropertyName = "PackageTargetFallback";
var mockProj = RunPackageDependenciesRuleOnPj(@"
{
""frameworks"": {
""netcoreapp1.0"" : {
""imports"": [""netstandard1.3"", ""net451""]
},
""netstandard1.3"" : {
""imports"": [""net451""]
},
""net451"" : {
""imports"": ""netstandard1.3""
}
}
}");
var imports = mockProj.Properties.Where(p => p.Name == importPropertyName);
imports.Should().HaveCount(3);
var netcoreappImport = imports.First(p => p.Condition.Contains("netcoreapp1.0"));
var netstandardImport = imports.First(p => p.Condition.Contains("netstandard1.3"));
var net451Import = imports.First(p => p.Condition.Contains("net451"));
netcoreappImport.Should().NotBe(netstandardImport);
netcoreappImport.Condition.Should().Be(" '$(TargetFramework)' == 'netcoreapp1.0' ");
netstandardImport.Condition.Should().Be(" '$(TargetFramework)' == 'netstandard1.3' ");
net451Import.Condition.Should().Be(" '$(TargetFramework)' == 'net451' ");
netcoreappImport.Value.Split(';').Should().BeEquivalentTo($"$({importPropertyName})", "netstandard1.3", "net451");
netstandardImport.Value.Split(';').Should().BeEquivalentTo($"$({importPropertyName})", "net451");
net451Import.Value.Split(';').Should().BeEquivalentTo($"$({importPropertyName})", "netstandard1.3");
}
private void EmitsPackageReferences(ProjectRootElement mockProj, params Tuple<string, string, string>[] packageSpecs) private void EmitsPackageReferences(ProjectRootElement mockProj, params Tuple<string, string, string>[] packageSpecs)
{ {
foreach (var packageSpec in packageSpecs) foreach (var packageSpec in packageSpecs)

View file

@ -56,6 +56,15 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
return new AndConstraint<DirectoryInfoAssertions>(this); return new AndConstraint<DirectoryInfoAssertions>(this);
} }
public AndConstraint<DirectoryInfoAssertions> HaveFilesMatching(string expectedFilesSearchPattern, SearchOption searchOption)
{
var matchingFileExists = _dirInfo.EnumerateFiles(expectedFilesSearchPattern, searchOption).Any();
Execute.Assertion.ForCondition(matchingFileExists == true)
.FailWith("Expected directory {0} to contain files matching {1}, but no matching file exists.",
_dirInfo.FullName, expectedFilesSearchPattern);
return new AndConstraint<DirectoryInfoAssertions>(this);
}
public AndConstraint<DirectoryInfoAssertions> NotHaveFiles(IEnumerable<string> expectedFiles) public AndConstraint<DirectoryInfoAssertions> NotHaveFiles(IEnumerable<string> expectedFiles)
{ {
foreach (var expectedFile in expectedFiles) foreach (var expectedFile in expectedFiles)
@ -66,6 +75,15 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
return new AndConstraint<DirectoryInfoAssertions>(this); return new AndConstraint<DirectoryInfoAssertions>(this);
} }
public AndConstraint<DirectoryInfoAssertions> NotHaveFilesMatching(string expectedFilesSearchPattern, SearchOption searchOption)
{
var matchingFileCount = _dirInfo.EnumerateFiles(expectedFilesSearchPattern, searchOption).Count();
Execute.Assertion.ForCondition(matchingFileCount == 0)
.FailWith("Found {0} files that should not exist in directory {1}. No file matching {2} should exist.",
matchingFileCount, _dirInfo.FullName, expectedFilesSearchPattern);
return new AndConstraint<DirectoryInfoAssertions>(this);
}
public AndConstraint<DirectoryInfoAssertions> HaveDirectory(string expectedDir) public AndConstraint<DirectoryInfoAssertions> HaveDirectory(string expectedDir)
{ {
var dir = _dirInfo.EnumerateDirectories(expectedDir, SearchOption.TopDirectoryOnly).SingleOrDefault(); var dir = _dirInfo.EnumerateDirectories(expectedDir, SearchOption.TopDirectoryOnly).SingleOrDefault();

View file

@ -0,0 +1,30 @@
// 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;
using Microsoft.DotNet.Cli.Utils;
using System.Runtime.InteropServices;
using Microsoft.DotNet.ProjectModel;
namespace Microsoft.DotNet.Tools.Test.Utilities
{
public sealed class Clean3Command : TestCommand
{
public Clean3Command()
: base("dotnet")
{
}
public override CommandResult Execute(string args = "")
{
args = $"clean3 {args}";
return base.Execute(args);
}
public override CommandResult ExecuteWithCapturedOutput(string args = "")
{
args = $"clean3 {args}";
return base.ExecuteWithCapturedOutput(args);
}
}
}

View file

@ -72,7 +72,9 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
if (!portable) if (!portable)
{ {
var runtime = string.IsNullOrEmpty(_runtime) ? RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier() : _runtime; var runtime = string.IsNullOrEmpty(_runtime) ?
DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier() :
_runtime;
return Path.Combine(config, framework, runtime, PublishSubfolderName); return Path.Combine(config, framework, runtime, PublishSubfolderName);
} }
else else

View file

@ -0,0 +1,31 @@
// 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 Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.InternalAbstractions;
using Microsoft.DotNet.PlatformAbstractions;
namespace Microsoft.DotNet.Tools.Test.Utilities
{
public static class DotnetLegacyRuntimeIdentifiers
{
public static string InferLegacyRestoreRuntimeIdentifier()
{
if (RuntimeEnvironment.OperatingSystemPlatform != Platform.Windows)
{
FrameworkDependencyFile fxDepsFile = new FrameworkDependencyFile();
return fxDepsFile.SupportsCurrentRuntime() ?
RuntimeEnvironment.GetRuntimeIdentifier() :
DotnetFiles.VersionFileObject.BuildRid;
}
else
{
var arch = RuntimeEnvironment.RuntimeArchitecture.ToLowerInvariant();
return "win7-" + arch;
}
}
}
}

View file

@ -2,7 +2,14 @@
"version": "1.0.0-*", "version": "1.0.0-*",
"description": "Microsoft.DotNet.Tools.Tests.Utilities Class Library", "description": "Microsoft.DotNet.Tools.Tests.Utilities Class Library",
"buildOptions": { "buildOptions": {
"keyFile": "../../tools/Key.snk" "keyFile": "../../tools/Key.snk",
"compile": {
"include": [
"**/*.cs",
"../../src/dotnet/DotnetFiles.cs"
]
}
}, },
"dependencies": { "dependencies": {
"FluentAssertions": "4.0.0", "FluentAssertions": "4.0.0",
@ -30,7 +37,7 @@
"System.Collections.Immutable": "1.2.0-rc2-24022", "System.Collections.Immutable": "1.2.0-rc2-24022",
"System.Net.NetworkInformation": "4.1.0-rc2-24022" "System.Net.NetworkInformation": "4.1.0-rc2-24022"
}, },
"net451": { "net46": {
"frameworkAssemblies": { "frameworkAssemblies": {
"System.Runtime": { "System.Runtime": {
"type": "build" "type": "build"

View file

@ -237,7 +237,7 @@ namespace Microsoft.DotNet.Tests
public void Tool_Command_Runs_Executable_Dependency_For_App_With_Config() public void Tool_Command_Runs_Executable_Dependency_For_App_With_Config()
{ {
var commandResult = new DependencyToolInvokerCommand { WorkingDirectory = _appWithConfigProjectRoot } var commandResult = new DependencyToolInvokerCommand { WorkingDirectory = _appWithConfigProjectRoot }
.Execute("desktop-binding-redirects", "net451", ""); .Execute("desktop-binding-redirects", "net46", "");
commandResult.Should().Pass(); commandResult.Should().Pass();
} }
@ -246,7 +246,7 @@ namespace Microsoft.DotNet.Tests
{ {
var appDirectory = Path.GetDirectoryName(_appWithoutConfigProjectRoot); var appDirectory = Path.GetDirectoryName(_appWithoutConfigProjectRoot);
var commandResult = new DependencyToolInvokerCommand { WorkingDirectory = _appWithoutConfigProjectRoot } var commandResult = new DependencyToolInvokerCommand { WorkingDirectory = _appWithoutConfigProjectRoot }
.Execute("desktop-binding-redirects", "net451", ""); .Execute("desktop-binding-redirects", "net46", "");
commandResult.Should().Pass(); commandResult.Should().Pass();
} }
} }

View file

@ -10,7 +10,7 @@ namespace Microsoft.DotNet.Tests
{ {
public class TestSetupFixture : TestBase public class TestSetupFixture : TestBase
{ {
private const string Framework = "net451"; private const string Framework = "net46";
private const string Config = "Debug"; private const string Config = "Debug";
private const string AppWithConfig = "AppWithRedirectsAndConfig"; private const string AppWithConfig = "AppWithRedirectsAndConfig";
private const string AppWithoutConfig = "AppWithRedirectsNoConfig"; private const string AppWithoutConfig = "AppWithRedirectsNoConfig";

View file

@ -9,9 +9,12 @@
} }
}, },
"frameworks": { "frameworks": {
"net451": { "net46": {
"frameworkAssemblies": { "frameworkAssemblies": {
"System.Configuration": "" "System.Configuration": ""
},
"dependencies": {
"System.Console": "4.0.0"
} }
} }
}, },

View file

@ -1,66 +0,0 @@
// 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;
using System.IO;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.TestFramework;
using Microsoft.DotNet.Tools.Test.Utilities;
using FluentAssertions;
using Xunit;
namespace Microsoft.DotNet.Tools.Compiler.Tests
{
public class GivenThatIWantToCompileFSharpPrograms
{
private readonly static string s_testProjectsRoot = Path.Combine(
AppContext.BaseDirectory,
"TestAssets",
"TestProjects",
"FSharpTestProjects");
[Fact]
public void Compilation_of_app_with_invalid_source_should_fail()
{
var testProject = Path.Combine(s_testProjectsRoot, "CompileFailApp", "project.json");
var buildCommand = new BuildCommand(testProject);
var oldDirectory = Directory.GetCurrentDirectory();
Directory.SetCurrentDirectory(Path.GetDirectoryName(testProject));
buildCommand.Execute().Should().Fail();
Directory.SetCurrentDirectory(oldDirectory);
}
[Fact]
public void Compilation_of_valid_app_should_succeed()
{
var testProject = Path.Combine(s_testProjectsRoot, "TestAppWithArgs", "project.json");
var buildCommand = new BuildCommand(testProject);
var oldDirectory = Directory.GetCurrentDirectory();
Directory.SetCurrentDirectory(Path.GetDirectoryName(testProject));
buildCommand.Execute().Should().Pass();
Directory.SetCurrentDirectory(oldDirectory);
}
[Fact]
public void Compilation_of_app_with_P2P_reference_to_fsharp_library_should_be_runnable()
{
var testProject = Path.Combine(s_testProjectsRoot, "TestApp", "project.json");
var runCommand = new RunCommand(testProject);
var oldDirectory = Directory.GetCurrentDirectory();
Directory.SetCurrentDirectory(Path.GetDirectoryName(testProject));
var result = runCommand.Execute();
result.Should().Pass();
Directory.SetCurrentDirectory(oldDirectory);
}
}
}

View file

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0.23107" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.23107</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>833ffee1-7eed-4f51-8dfd-946d48893d6e</ProjectGuid>
<RootNamespace>Microsoft.DotNet.Tools.Compiler.Tests</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View file

@ -1,46 +0,0 @@
{
"version": "1.0.0-*",
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
},
"Microsoft.DotNet.Tools.Tests.Utilities": {
"target": "project"
},
"Microsoft.DotNet.Cli.Utils": {
"target": "project"
},
"xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-350904-49"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.4",
"portable-net451+win8"
]
}
},
"testRunner": "xunit",
"publishOptions": {
"include": [
"../../TestAssets/TestProjects/FSharpTestProjects/CompileFailApp/**/*",
"../../TestAssets/TestProjects/FSharpTestProjects/TestApp/**/*",
"../../TestAssets/TestProjects/FSharpTestProjects/TestAppWithArgs/**/*",
"../../TestAssets/TestProjects/FSharpTestProjects/TestLibrary/**/*",
"../../TestAssets/TestProjects/FSharpTestProjects/global.json"
]
},
"buildOptions": {
"copyToOutput": {
"include": [
"../../TestAssets/TestProjects/FSharpTestProjects/CompileFailApp/**/*",
"../../TestAssets/TestProjects/FSharpTestProjects/TestApp/**/*",
"../../TestAssets/TestProjects/FSharpTestProjects/TestAppWithArgs/**/*",
"../../TestAssets/TestProjects/FSharpTestProjects/TestLibrary/**/*",
"../../TestAssets/TestProjects/FSharpTestProjects/global.json"
]
}
}
}

View file

@ -8,6 +8,7 @@ using FluentAssertions;
using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.InternalAbstractions; using Microsoft.DotNet.InternalAbstractions;
using Microsoft.DotNet.ProjectModel; using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.Tools.Test.Utilities;
using Moq; using Moq;
using NuGet.Frameworks; using NuGet.Frameworks;
using Xunit; using Xunit;
@ -69,7 +70,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
[Fact] [Fact]
public void It_passes_a_RuntimeOutputDir_variable_to_the_pre_compile_scripts_if_rid_is_set_in_the_ProjectContext() public void It_passes_a_RuntimeOutputDir_variable_to_the_pre_compile_scripts_if_rid_is_set_in_the_ProjectContext()
{ {
var rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier(); var rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
var fixture = ScriptVariablesFixture.GetFixtureWithRids(rid); var fixture = ScriptVariablesFixture.GetFixtureWithRids(rid);
fixture.PreCompileScriptVariables.Should().ContainKey("compile:RuntimeOutputDir"); fixture.PreCompileScriptVariables.Should().ContainKey("compile:RuntimeOutputDir");
fixture.PreCompileScriptVariables["compile:RuntimeOutputDir"].Should().Be(fixture.RuntimeOutputDir); fixture.PreCompileScriptVariables["compile:RuntimeOutputDir"].Should().Be(fixture.RuntimeOutputDir);
@ -128,7 +129,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
[Fact] [Fact]
public void It_passes_a_RuntimeOutputDir_variable_to_the_post_compile_scripts_if_rid_is_set_in_the_ProjectContext() public void It_passes_a_RuntimeOutputDir_variable_to_the_post_compile_scripts_if_rid_is_set_in_the_ProjectContext()
{ {
var rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier(); var rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
var fixture = ScriptVariablesFixture.GetFixtureWithRids(rid); var fixture = ScriptVariablesFixture.GetFixtureWithRids(rid);
fixture.PostCompileScriptVariables.Should().ContainKey("compile:RuntimeOutputDir"); fixture.PostCompileScriptVariables.Should().ContainKey("compile:RuntimeOutputDir");
fixture.PostCompileScriptVariables["compile:RuntimeOutputDir"].Should().Be(fixture.RuntimeOutputDir); fixture.PostCompileScriptVariables["compile:RuntimeOutputDir"].Should().Be(fixture.RuntimeOutputDir);

View file

@ -4,8 +4,12 @@
"keyFile": "../../tools/Key.snk", "keyFile": "../../tools/Key.snk",
"copyToOutput": { "copyToOutput": {
"include": [ "include": [
"../../TestAssets/TestProjects/TestAppWithLibrary/**/*" "../../TestAssets/TestProjects/TestAppWithLibrary/**/*",
] "../../artifacts/*/stage2/sdk/*/.version"
],
"mappings": {
".version": "../../artifacts/*/stage2/sdk/*/.version"
}
} }
}, },
"dependencies": { "dependencies": {
@ -29,6 +33,9 @@
"Microsoft.DotNet.ProjectModel": { "Microsoft.DotNet.ProjectModel": {
"target": "project" "target": "project"
}, },
"Microsoft.DotNet.Tools.Tests.Utilities": {
"target": "project"
},
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-350904-49", "dotnet-test-xunit": "1.0.0-rc2-350904-49",
"moq.netcore": "4.4.0-beta8", "moq.netcore": "4.4.0-beta8",

View file

@ -268,8 +268,54 @@ namespace Microsoft.DotNet.Migration.Tests
outputsIdentical.Should().BeTrue(); outputsIdentical.Should().BeTrue();
VerifyAllMSBuildOutputsRunnable(projectDirectory); VerifyAllMSBuildOutputsRunnable(projectDirectory);
} }
[Theory]
// https://github.com/dotnet/cli/issues/4313
[InlineData(true)]
[InlineData(false)]
public void Migration_outputs_error_when_no_projects_found(bool useGlobalJson)
{
var projectDirectory = TestAssetsManager.CreateTestDirectory("Migration_outputs_error_when_no_projects_found");
private void VerifyMigration(IEnumerable<string> expectedProjects, string rootDir) string argstr = string.Empty;
string errorMessage = string.Empty;
if (useGlobalJson)
{
var globalJsonPath = Path.Combine(projectDirectory.Path, "global.json");
using (FileStream fs = File.Create(globalJsonPath))
{
using (StreamWriter sw = new StreamWriter(fs))
{
sw.WriteLine("{");
sw.WriteLine("\"projects\": [ \".\" ]");
sw.WriteLine("}");
}
}
argstr = globalJsonPath;
errorMessage = "Unable to find any projects in global.json";
}
else
{
argstr = projectDirectory.Path;
errorMessage = $"No project.json file found in '{projectDirectory.Path}'";
}
var result = new TestCommand("dotnet")
.WithWorkingDirectory(projectDirectory.Path)
.ExecuteWithCapturedOutput($"migrate {argstr}");
// Expecting an error exit code.
result.ExitCode.Should().Be(1);
// Verify the error messages. Note that debug builds also show the call stack, so we search
// for the error strings that should be present (rather than an exact match).
result.StdErr.Should().Contain(errorMessage);
result.StdErr.Should().Contain("Migration failed.");
}
private void VerifyMigration(IEnumerable<string> expectedProjects, string rootDir)
{ {
var migratedProjects = Directory.EnumerateFiles(rootDir, "project.json", SearchOption.AllDirectories) var migratedProjects = Directory.EnumerateFiles(rootDir, "project.json", SearchOption.AllDirectories)
.Where(s => Directory.EnumerateFiles(Path.GetDirectoryName(s), "*.csproj").Count() == 1) .Where(s => Directory.EnumerateFiles(Path.GetDirectoryName(s), "*.csproj").Count() == 1)

View file

@ -41,5 +41,39 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
.And .And
.HaveStdOutContaining("You want me to say 'GreatScott'"); .HaveStdOutContaining("You want me to say 'GreatScott'");
} }
[Theory]
// https://github.com/dotnet/cli/issues/4293
[InlineData("build", false)]
[InlineData("pack", false)]
[InlineData("publish", false)]
[InlineData("restore", false)]
[InlineData("run", false)]
[InlineData("build3", true)]
[InlineData("clean3", true)]
[InlineData("pack3", true)]
[InlineData("publish3", true)]
[InlineData("restore3", true)]
[InlineData("run3", true)]
public void ItMSBuildHelpText(string commandName, bool isMSBuildCommand)
{
const string MSBuildHelpText = " Any extra options that should be passed to MSBuild. See 'dotnet msbuild -h' for available options.";
var projectDirectory = TestAssetsManager.CreateTestDirectory("ItContainsMSBuildHelpText");
var result = new TestCommand("dotnet")
.WithWorkingDirectory(projectDirectory.Path)
.ExecuteWithCapturedOutput($"{commandName} --help");
result.ExitCode.Should().Be(0);
if (isMSBuildCommand)
{
result.StdOut.Should().Contain(MSBuildHelpText);
}
else
{
result.StdOut.Should().NotContain(MSBuildHelpText);
}
}
} }
} }

View file

@ -54,7 +54,9 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
[InlineData("KestrelDesktop", "http://localhost:20207", "win7-x86", "libuv.dll", false)] [InlineData("KestrelDesktop", "http://localhost:20207", "win7-x86", "libuv.dll", false)]
public async Task DesktopApp_WithKestrel_WorksWhenPublished(string project, string url, string runtime, string libuvName, bool forceRunnable) public async Task DesktopApp_WithKestrel_WorksWhenPublished(string project, string url, string runtime, string libuvName, bool forceRunnable)
{ {
var runnable = forceRunnable || string.IsNullOrEmpty(runtime) || (RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier().Contains(runtime)); var runnable = forceRunnable ||
string.IsNullOrEmpty(runtime) ||
(DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier().Contains(runtime));
var testInstance = GetTestInstance() var testInstance = GetTestInstance()
.WithLockFiles(); .WithLockFiles();

View file

@ -58,11 +58,11 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
{ {
new object[] { "1", "", "", "", "" }, new object[] { "1", "", "", "", "" },
new object[] { "2", "netcoreapp1.0", "", "", "" }, new object[] { "2", "netcoreapp1.0", "", "", "" },
new object[] { "3", "", RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier(), "", "" }, new object[] { "3", "", DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier(), "", "" },
new object[] { "4", "", "", "Release", "" }, new object[] { "4", "", "", "Release", "" },
new object[] { "5", "", "", "", "some/dir"}, new object[] { "5", "", "", "", "some/dir"},
new object[] { "6", "", "", "", "some/dir/with spaces" }, new object[] { "6", "", "", "", "some/dir/with spaces" },
new object[] { "7", "netcoreapp1.0", RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier(), "Debug", "some/dir" }, new object[] { "7", "netcoreapp1.0", DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier(), "Debug", "some/dir" },
}; };
} }
} }
@ -221,7 +221,10 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
publishCommand.GetOutputDirectory().Should().HaveFile("Newtonsoft.Json.dll"); publishCommand.GetOutputDirectory().Should().HaveFile("Newtonsoft.Json.dll");
publishCommand.GetOutputDirectory().Delete(true); publishCommand.GetOutputDirectory().Delete(true);
publishCommand = new PublishCommand(lesserTestProject, "netcoreapp1.0", RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier()); publishCommand = new PublishCommand(
lesserTestProject,
"netcoreapp1.0",
DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier());
publishCommand.Execute().Should().Pass(); publishCommand.Execute().Should().Pass();
publishCommand.GetOutputDirectory().Should().HaveFile("TestLibraryLesser.dll"); publishCommand.GetOutputDirectory().Should().HaveFile("TestLibraryLesser.dll");

View file

@ -1,5 +1,15 @@
{ {
"version": "1.0.0-*", "version": "1.0.0-*",
"buildOptions": {
"copyToOutput": {
"include": [
"../../artifacts/*/stage2/sdk/*/.version"
],
"mappings": {
".version": "../../artifacts/*/stage2/sdk/*/.version"
}
}
},
"dependencies": { "dependencies": {
"Microsoft.NETCore.App": { "Microsoft.NETCore.App": {
"type": "platform", "type": "platform",

View file

@ -53,7 +53,7 @@ namespace Microsoft.DotNet.Cli.Publish3.Tests
.CreateTestInstance(testAppName); .CreateTestInstance(testAppName);
var testProjectDirectory = testInstance.TestRoot; var testProjectDirectory = testInstance.TestRoot;
var rid = RuntimeEnvironment.GetRuntimeIdentifier(); var rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
new Publish3Command() new Publish3Command()
.WithFramework("netcoreapp1.0") .WithFramework("netcoreapp1.0")

View file

@ -1,5 +1,15 @@
{ {
"version": "1.0.0-*", "version": "1.0.0-*",
"buildOptions": {
"copyToOutput": {
"include": [
"../../artifacts/*/stage2/sdk/*/.version"
],
"mappings": {
".version": "../../artifacts/*/stage2/sdk/*/.version"
}
}
},
"dependencies": { "dependencies": {
"Microsoft.NETCore.App": { "Microsoft.NETCore.App": {
"type": "platform", "type": "platform",

View file

@ -1,5 +1,15 @@
{ {
"version": "1.0.0-*", "version": "1.0.0-*",
"buildOptions": {
"copyToOutput": {
"include": [
"../../artifacts/*/stage2/sdk/*/.version"
],
"mappings": {
".version": "../../artifacts/*/stage2/sdk/*/.version"
}
}
},
"dependencies": { "dependencies": {
"Microsoft.NETCore.App": { "Microsoft.NETCore.App": {
"type": "platform", "type": "platform",

View file

@ -17,7 +17,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
{ {
private readonly string _projectFilePath; private readonly string _projectFilePath;
private readonly string _defaultNetCoreAppOutputPath; private readonly string _defaultNetCoreAppOutputPath;
private readonly string _defaultNet451OutputPath; private readonly string _defaultNet46OutputPath;
public GivenThatWeWantToRunTestsForMultipleTFMsInTheConsole() public GivenThatWeWantToRunTestsForMultipleTFMsInTheConsole()
{ {
@ -36,7 +36,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
new RestoreCommand() { WorkingDirectory = testInstance.TestRoot }.Execute().Should().Pass(); new RestoreCommand() { WorkingDirectory = testInstance.TestRoot }.Execute().Should().Pass();
_defaultNetCoreAppOutputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "netcoreapp1.0"); _defaultNetCoreAppOutputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "netcoreapp1.0");
_defaultNet451OutputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "net451", RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First()); _defaultNet46OutputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "net46", RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First());
} }
[WindowsOnlyFact] [WindowsOnlyFact]
@ -46,18 +46,18 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
var result = testCommand var result = testCommand
.ExecuteWithCapturedOutput($"{_projectFilePath}"); .ExecuteWithCapturedOutput($"{_projectFilePath}");
result.Should().Pass(); result.Should().Pass();
result.StdOut.Should().Contain("Skipped for NET451"); result.StdOut.Should().Contain("Skipped for NET46");
result.StdOut.Should().Contain("Skipped for NETCOREAPP1.0"); result.StdOut.Should().Contain("Skipped for NETCOREAPP1.0");
} }
[WindowsOnlyFact] [WindowsOnlyFact]
public void It_builds_and_runs_tests_for_net451() public void It_builds_and_runs_tests_for_net46()
{ {
var testCommand = new DotnetTestCommand(); var testCommand = new DotnetTestCommand();
var result = testCommand var result = testCommand
.ExecuteWithCapturedOutput($"{_projectFilePath} -f net451"); .ExecuteWithCapturedOutput($"{_projectFilePath} -f net46");
result.Should().Pass(); result.Should().Pass();
result.StdOut.Should().Contain($"Skipped for NET451"); result.StdOut.Should().Contain($"Skipped for NET46");
result.StdOut.Should().NotContain($"Skipped for NETCOREAPP1.0"); result.StdOut.Should().NotContain($"Skipped for NETCOREAPP1.0");
} }
@ -69,7 +69,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
.ExecuteWithCapturedOutput($"{_projectFilePath} -f netcoreapp1.0"); .ExecuteWithCapturedOutput($"{_projectFilePath} -f netcoreapp1.0");
result.Should().Pass(); result.Should().Pass();
result.StdOut.Should().Contain($"Skipped for NETCOREAPP1.0"); result.StdOut.Should().Contain($"Skipped for NETCOREAPP1.0");
result.StdOut.Should().NotContain($"Skipped for NET451"); result.StdOut.Should().NotContain($"Skipped for NET46");
} }
[Fact] [Fact]
@ -103,15 +103,15 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
} }
[WindowsOnlyFact] [WindowsOnlyFact]
public void It_skips_build_when_the_no_build_flag_is_passed_for_net451() public void It_skips_build_when_the_no_build_flag_is_passed_for_net46()
{ {
var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First(); var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First();
var buildCommand = new BuildCommand(_projectFilePath); var buildCommand = new BuildCommand(_projectFilePath);
var result = buildCommand.Execute($"-f net451 -r {rid} -o {_defaultNet451OutputPath}"); var result = buildCommand.Execute($"-f net46 -r {rid} -o {_defaultNet46OutputPath}");
result.Should().Pass(); result.Should().Pass();
var testCommand = new DotnetTestCommand(); var testCommand = new DotnetTestCommand();
result = testCommand.Execute($"{_projectFilePath} -f net451 -r {rid} -o {_defaultNet451OutputPath} --no-build"); result = testCommand.Execute($"{_projectFilePath} -f net46 -r {rid} -o {_defaultNet46OutputPath} --no-build");
result.Should().Pass(); result.Should().Pass();
} }
@ -142,7 +142,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
.ExecuteWithCapturedOutput($"{_projectFilePath}"); .ExecuteWithCapturedOutput($"{_projectFilePath}");
result.Should().Fail(); result.Should().Fail();
result.StdOut.Should().Contain("Failing in NET451"); result.StdOut.Should().Contain("Failing in NET46");
result.StdOut.Should().Contain("Failing in NETCOREAPP1.0"); result.StdOut.Should().Contain("Failing in NETCOREAPP1.0");
} }

View file

@ -18,7 +18,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
{ {
private string _projectFilePath; private string _projectFilePath;
private string _netCoreAppOutputPath; private string _netCoreAppOutputPath;
private string _net451OutputPath; private string _net46OutputPath;
private void Setup([CallerMemberName] string callingMethod = "") private void Setup([CallerMemberName] string callingMethod = "")
{ {
@ -44,8 +44,8 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
if (RuntimeEnvironment.OperatingSystemPlatform == Platform.Windows) if (RuntimeEnvironment.OperatingSystemPlatform == Platform.Windows)
{ {
var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First(); var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First();
_net451OutputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "net451", rid); _net46OutputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "net46", rid);
result = buildCommand.Execute($"-f net451 -r {rid} -o {_net451OutputPath}"); result = buildCommand.Execute($"-f net46 -r {rid} -o {_net46OutputPath}");
result.Should().Pass(); result.Should().Pass();
} }
} }
@ -70,7 +70,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
} }
[WindowsOnlyFact(Skip="https://github.com/xunit/xunit/issues/934")] [WindowsOnlyFact(Skip="https://github.com/xunit/xunit/issues/934")]
public void It_discovers_tests_for_the_ProjectWithTestsWithNet451() public void It_discovers_tests_for_the_ProjectWithTestsWithNet46()
{ {
Setup(); Setup();
@ -80,7 +80,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First(); var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First();
var testCommand = new DotnetTestCommand(); var testCommand = new DotnetTestCommand();
var result = testCommand.Execute($"{_projectFilePath} -f net451 -r {rid} -o {_net451OutputPath} --port {adapter.Port} --no-build"); var result = testCommand.Execute($"{_projectFilePath} -f net46 -r {rid} -o {_net46OutputPath} --port {adapter.Port} --no-build");
result.Should().Pass(); result.Should().Pass();
adapter.Messages["TestSession.Connected"].Count.Should().Be(1); adapter.Messages["TestSession.Connected"].Count.Should().Be(1);
@ -111,7 +111,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
} }
[WindowsOnlyFact(Skip="https://github.com/xunit/xunit/issues/934")] [WindowsOnlyFact(Skip="https://github.com/xunit/xunit/issues/934")]
public void It_runs_tests_for_net451() public void It_runs_tests_for_net46()
{ {
Setup(); Setup();
@ -121,7 +121,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
var testCommand = new DotnetTestCommand(); var testCommand = new DotnetTestCommand();
var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First(); var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First();
var result = testCommand.Execute($"{_projectFilePath} -f net451 -r {rid} -o {_net451OutputPath} --port {adapter.Port} --no-build"); var result = testCommand.Execute($"{_projectFilePath} -f net46 -r {rid} -o {_net46OutputPath} --port {adapter.Port} --no-build");
result.Should().Pass(); result.Should().Pass();
adapter.Messages["TestSession.Connected"].Count.Should().Be(1); adapter.Messages["TestSession.Connected"].Count.Should().Be(1);

View file

@ -22,7 +22,7 @@ namespace Microsoft.DotNet.Tests
{ {
get get
{ {
var rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier(); var rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
var projectOutputPath = $"AppWithDirectDepDesktopAndPortable\\bin\\Debug\\net451\\{rid}\\dotnet-desktop-and-portable.exe"; var projectOutputPath = $"AppWithDirectDepDesktopAndPortable\\bin\\Debug\\net451\\{rid}\\dotnet-desktop-and-portable.exe";
return new[] return new[]
{ {
@ -36,7 +36,7 @@ namespace Microsoft.DotNet.Tests
{ {
get get
{ {
var rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier(); var rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
var projectOutputPath = $"LibraryWithDirectDependencyDesktopAndPortable\\bin\\Debug\\net451\\dotnet-desktop-and-portable.exe"; var projectOutputPath = $"LibraryWithDirectDependencyDesktopAndPortable\\bin\\Debug\\net451\\dotnet-desktop-and-portable.exe";
return new[] return new[]
{ {