Merge remote-tracking branch 'refs/remotes/origin/feature/msbuild'

Conflicts:
	src/dotnet/Program.cs
This commit is contained in:
Piotr Puszkiewicz 2016-08-18 18:08:45 -07:00
commit 578adf072c
81 changed files with 625 additions and 286 deletions

View file

@ -8,7 +8,7 @@
"type": "platform", "type": "platform",
"version": "1.0.0" "version": "1.0.0"
}, },
"Microsoft.Extensions.DependencyModel": "1.0.1-beta-000914" "Microsoft.Extensions.DependencyModel": "1.0.1-beta-000919"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -1,7 +1,7 @@
{ {
"version": "1.0.0-*", "version": "1.0.0-*",
"dependencies": { "dependencies": {
"Microsoft.Extensions.DependencyModel": "1.0.1-beta-003395" "Microsoft.Extensions.DependencyModel": "1.0.1-beta-000919"
}, },
"frameworks": { "frameworks": {
"netstandard1.6": { "netstandard1.6": {

View file

@ -1,7 +1,7 @@
{ {
"version": "1.0.0-*", "version": "1.0.0-*",
"dependencies": { "dependencies": {
"dotnet-test-xunit": "1.0.0-rc2-318883-21", "dotnet-test-xunit": "1.0.0-rc2-330423-54",
"xunit": "2.2.0-beta3-build3330" "xunit": "2.2.0-beta3-build3330"
}, },
"frameworks": { "frameworks": {

View file

@ -8,7 +8,7 @@
"System.Linq.Expressions": "4.1.0", "System.Linq.Expressions": "4.1.0",
"System.Runtime.Serialization.Primitives": "4.1.1", "System.Runtime.Serialization.Primitives": "4.1.1",
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21", "dotnet-test-xunit": "1.0.0-rc2-330423-54",
"Microsoft.DotNet.InternalAbstractions": { "Microsoft.DotNet.InternalAbstractions": {
"target": "project" "target": "project"
} }

View file

@ -7,7 +7,7 @@
"Microsoft.NETCore.App": "1.0.0", "Microsoft.NETCore.App": "1.0.0",
"Microsoft.CSharp": "4.0.1", "Microsoft.CSharp": "4.0.1",
"System.Dynamic.Runtime": "4.0.11", "System.Dynamic.Runtime": "4.0.11",
"System.Reflection.Metadata": "1.3.0", "System.Reflection.Metadata": "1.4.1-beta-24410-02",
"System.Runtime.Serialization.Primitives": "4.1.1", "System.Runtime.Serialization.Primitives": "4.1.1",
"System.Xml.XmlSerializer": "4.0.11", "System.Xml.XmlSerializer": "4.0.11",
"WindowsAzure.Storage": "6.2.2-preview" "WindowsAzure.Storage": "6.2.2-preview"

View file

@ -5,14 +5,14 @@
<PropertyGroup> <PropertyGroup>
<BinaryToCorehostifyRelDir>runtimes/any/native</BinaryToCorehostifyRelDir> <BinaryToCorehostifyRelDir>runtimes/any/native</BinaryToCorehostifyRelDir>
<CoreSDKDir>$(RepoRoot)/resources/MSBuildImports</CoreSDKDir> <MSBuildImportsDir>$(RepoRoot)/resources/MSBuildImports</MSBuildImportsDir>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PublishOutputExtensions Include="$(ExeExtension);.dll;.pdb;.deps.json;.runtimeconfig.json" /> <PublishOutputExtensions Include="$(ExeExtension);.dll;.pdb;.deps.json;.runtimeconfig.json" />
<FilesToMove Include="$(BinaryToCorehostifyRelDir)/csc.exe;$(BinaryToCorehostifyRelDir)/MSBuild.exe;" /> <FilesToMove Include="$(BinaryToCorehostifyRelDir)/csc.exe;$(BinaryToCorehostifyRelDir)/MSBuild.exe;" />
<BundledTools Include="csc;MSBuild;NuGet.CommandLine.XPlat;dotnet" /> <BundledTools Include="csc;MSBuild;NuGet.CommandLine.XPlat;dotnet" />
<CoreSDKContent Include="$(CoreSDKDir)/**/*" /> <MSBuildImportsContent Include="$(MSBuildImportsDir)/**/*" />
</ItemGroup> </ItemGroup>
<Target Name="Compile" DependsOnTargets="Prepare; <Target Name="Compile" DependsOnTargets="Prepare;
@ -165,7 +165,7 @@
DestinationFiles="$(SdkOutputDirectory)/$(HostPolicyBaseName)" /> DestinationFiles="$(SdkOutputDirectory)/$(HostPolicyBaseName)" />
<!-- copy core sdk --> <!-- copy core sdk -->
<Copy SourceFiles="@(CoreSDKContent)" <Copy SourceFiles="@(MSBuildImportsContent)"
DestinationFolder="$(SdkOutputDirectory)/%(RecursiveDir)" /> DestinationFolder="$(SdkOutputDirectory)/%(RecursiveDir)" />
<!-- Crossgen the Shared Framework --> <!-- Crossgen the Shared Framework -->
@ -197,8 +197,8 @@
CrossgenPath="$(CrossgenPath)" CrossgenPath="$(CrossgenPath)"
ReadyToRun="True" ReadyToRun="True"
PlatformAssemblyPaths="@(PlatformAssemblies); PlatformAssemblyPaths="@(PlatformAssemblies);
$(SharedFrameworkNameVersionPath); @(CompileStageSdkDirectories);
@(CompileStageSdkDirectories)" /> $(SharedFrameworkNameVersionPath)" />
<!-- Generate .version file --> <!-- Generate .version file -->
<WriteLinesToFile File="$(SdkOutputDirectory)/.version" <WriteLinesToFile File="$(SdkOutputDirectory)/.version"

View file

@ -10,7 +10,7 @@
<Import Project="test/TestAssetProjects.targets" /> <Import Project="test/TestAssetProjects.targets" />
<Import Project="test/TestProjects.targets" /> <Import Project="test/TestProjects.targets" />
<Target Name="Test" <Target Name="Test"
DependsOnTargets="PrepareTests; DependsOnTargets="PrepareTests;
BuildTestAssets; BuildTestAssets;
BuildTests;"> BuildTests;">
@ -27,13 +27,28 @@
<TestTaskEnvironmentVariables Include="TEST_ARTIFACTS=$(TestArtifactsEnv)" /> <TestTaskEnvironmentVariables Include="TEST_ARTIFACTS=$(TestArtifactsEnv)" />
</ItemGroup> </ItemGroup>
<DotNetTest WorkingDirectory="%(TestProjects.ProjectDir)" <PropertyGroup>
EnvironmentVariables="@(TestTaskEnvironmentVariables)" <RunTestEnvironmentVariables>@(TestTaskEnvironmentVariables)</RunTestEnvironmentVariables>
ToolPath="$(Stage2Directory)" </PropertyGroup>
Configuration="$(Configuration)"
NoBuild="True" <ItemGroup>
NoTrait="category=failing" <ProjectsToTest Include="build/test/RunTest.proj">
Xml="$(TestResultXmlDir)/%(TestProjects.OutputName)-testResults.xml" /> <Properties>
CLIBuildDll=$(CLIBuildDll);
Configuration=$(Configuration);
EnvironmentVariables=$(RunTestEnvironmentVariables);
TestProjectName=%(TestProjects.OutputName);
TestResultXmlDir=$(TestResultXmlDir);
ToolPath=$(Stage2Directory);
WorkingDirectory=%(TestProjects.ProjectDir)
</Properties>
</ProjectsToTest>
</ItemGroup>
<MSBuild
BuildInParallel="True"
Projects="@(ProjectsToTest)">
</MSBuild>
</Target> </Target>
<Target Name="PrepareTests" <Target Name="PrepareTests"
@ -50,7 +65,7 @@
</PropertyGroup> </PropertyGroup>
</Target> </Target>
<Target Name="BuildTests" <Target Name="BuildTests"
DependsOnTargets="RestoreTests; DependsOnTargets="RestoreTests;
SetupTestProjectData;" SetupTestProjectData;"
Inputs="%(TestProjects.BuildInputs)" Inputs="%(TestProjects.BuildInputs)"
@ -63,25 +78,25 @@
<Target Name="RestoreTests" <Target Name="RestoreTests"
DependsOnTargets="CreateTestAssetPackageNuPkgs; DependsOnTargets="CreateTestAssetPackageNuPkgs;
CleanTestProjectsBinObj; CleanTestProjectsBinObjProjectJson;
SetupRestoreTestsInputs;" SetupRestoreTestsInputs;"
Inputs="@(RestoreTestsInputs)" Inputs="@(RestoreTestsInputs)"
Outputs="@(RestoreTestsInputs->'%(RelativeDir)project.lock.json')"> Outputs="@(RestoreTestsInputs->'%(RelativeDir)project.lock.json')">
<CallTarget Targets="CleanTestProjectsLockFiles"/> <CallTarget Targets="CleanTestProjectsLockFiles"/>
<DotNetRestore FallbackSource="$(TestPackagesDir)" <DotNetRestore FallbackSource="$(TestPackagesDir)"
ToolPath="$(DotnetUnderTest)" ToolPath="$(DotnetUnderTest)"
WorkingDirectory="$(TestDirectory)" /> WorkingDirectory="$(TestDirectory)" />
</Target> </Target>
<Target Name="CleanTestProjectsBinObj" <Target Name="CleanTestProjectsBinObjProjectJson"
DependsOnTargets="SetupRestoreTestsInputs;" DependsOnTargets="SetupRestoreTestsInputs;"
Inputs="@(RestoreTestsInputs)" Inputs="@(RestoreTestsInputs)"
Outputs="@(RestoreTestsInputs->'%(RelativeDir)project.lock.json')"> Outputs="@(RestoreTestsInputs->'%(RelativeDir)project.lock.json')">
<ItemGroup> <ItemGroup>
<FilesToDelete Include="$(TestDirectory)**/bin/**/*.*" /> <FilesToDelete Include="$(TestDirectory)**/bin/**/project.json" />
<FilesToDelete Include="$(TestDirectory)**/obj/**/*.*" /> <FilesToDelete Include="$(TestDirectory)**/obj/**/project.json" />
</ItemGroup> </ItemGroup>
<Delete Files="@(FilesToDelete)" /> <Delete Files="@(FilesToDelete)" />
@ -122,7 +137,7 @@
Outputs="@(RestoreTestAssetProjectsInputs->'%(RelativeDir)/project.lock.json')"> Outputs="@(RestoreTestAssetProjectsInputs->'%(RelativeDir)/project.lock.json')">
<DotNetRestore FallbackSource="$(TestPackagesDir)" <DotNetRestore FallbackSource="$(TestPackagesDir)"
ToolPath="$(DotnetUnderTest)" ToolPath="$(DotnetUnderTest)"
WorkingDirectory="$(RepoRoot)TestAssets/TestProjects/" /> WorkingDirectory="$(RepoRoot)TestAssets/TestProjects/" />
</Target> </Target>
@ -136,23 +151,23 @@
<ItemGroup> <ItemGroup>
<TestAssetProjectsLockFiles Include="$(RepoRoot)/TestAssets/TestProjects/**/project.lock.json" /> <TestAssetProjectsLockFiles Include="$(RepoRoot)/TestAssets/TestProjects/**/project.lock.json" />
</ItemGroup> </ItemGroup>
<Delete Files="@(TestAssetProjectsLockFiles)" /> <Delete Files="@(TestAssetProjectsLockFiles)" />
</Target> </Target>
<Target Name="CleanTestProjectsLockFiles" > <Target Name="CleanTestProjectsLockFiles" >
<ItemGroup> <ItemGroup>
<TestProjectsLockFiles Include="$(RepoRoot)/test/**/project.lock.json" /> <TestProjectsLockFiles Include="$(RepoRoot)/test/**/project.lock.json" />
</ItemGroup> </ItemGroup>
<Delete Files="@(TestProjectsLockFiles)" /> <Delete Files="@(TestProjectsLockFiles)" />
</Target> </Target>
<Target Name="BuildDesktopTestAssetProjects" <Target Name="BuildDesktopTestAssetProjects"
Condition=" '$(IsDesktopAvailable)' == 'True' " Condition=" '$(IsDesktopAvailable)' == 'True' "
DependsOnTargets="RestoreDesktopTestAssetProjects"> DependsOnTargets="RestoreDesktopTestAssetProjects">
<ItemGroup> <ItemGroup>
<NoAutoBuildDesktopTestAssets Include="$(RepoRoot)TestAssets\DesktopTestProjects\**\.noautobuild" /> <NoAutoBuildDesktopTestAssets Include="$(RepoRoot)TestAssets\DesktopTestProjects\**\.noautobuild" />
<NoAutoBuildDesktopTestAssetProjects Include="%(NoAutoBuildDesktopTestAssets.RelativeDir)project.json" /> <NoAutoBuildDesktopTestAssetProjects Include="%(NoAutoBuildDesktopTestAssets.RelativeDir)project.json" />
<BuildableDesktopTestAssetProjects Include="$(RepoRoot)TestAssets\DesktopTestProjects\**\project.json" <BuildableDesktopTestAssetProjects Include="$(RepoRoot)TestAssets\DesktopTestProjects\**\project.json"
Exclude="@(NoAutoBuildDesktopTestAssetProjects)" /> Exclude="@(NoAutoBuildDesktopTestAssetProjects)" />
</ItemGroup> </ItemGroup>
@ -167,14 +182,14 @@
</Target> </Target>
<Target Name="RestoreDesktopTestAssetProjects" <Target Name="RestoreDesktopTestAssetProjects"
Condition=" '$(IsDesktopAvailable)' == 'True' " Condition=" '$(IsDesktopAvailable)' == 'True' "
DependsOnTargets="CreateTestAssetPackageNuPkgs; DependsOnTargets="CreateTestAssetPackageNuPkgs;
SetupRestoreDesktopTestAssetProjectsInputs;" SetupRestoreDesktopTestAssetProjectsInputs;"
Inputs="@(RestoreDesktopTestAssetProjectsInputs)" Inputs="@(RestoreDesktopTestAssetProjectsInputs)"
Outputs="@(RestoreDesktopTestAssetProjectsInputs->'%(RelativeDir)/project.lock.json')"> Outputs="@(RestoreDesktopTestAssetProjectsInputs->'%(RelativeDir)/project.lock.json')">
<DotNetRestore FallbackSource="$(TestPackagesDir)" <DotNetRestore FallbackSource="$(TestPackagesDir)"
ToolPath="$(DotnetUnderTest)" ToolPath="$(DotnetUnderTest)"
WorkingDirectory="$(RepoRoot)TestAssets\DesktopTestProjects\" /> WorkingDirectory="$(RepoRoot)TestAssets\DesktopTestProjects\" />
</Target> </Target>
@ -184,7 +199,7 @@
</ItemGroup> </ItemGroup>
</Target> </Target>
<Target Name="CreateTestAssetPackageNuPkgs" <Target Name="CreateTestAssetPackageNuPkgs"
DependsOnTargets="BuildTestAssetPackageProjects; DependsOnTargets="BuildTestAssetPackageProjects;
SetupTestPackageProjectData;" SetupTestPackageProjectData;"
Inputs="%(TestPackageProject.PackInputs)" Inputs="%(TestPackageProject.PackInputs)"
@ -210,14 +225,14 @@
ToolPath="$(DotnetUnderTest)" ToolPath="$(DotnetUnderTest)"
WorkingDirectory="%(BuildableTestAssetProjects.RelativeDir)" /> WorkingDirectory="%(BuildableTestAssetProjects.RelativeDir)" />
</Target> </Target>
<Target Name="RestoreTestAssetPackageProjects" <Target Name="RestoreTestAssetPackageProjects"
DependsOnTargets="PrepareTests; DependsOnTargets="PrepareTests;
SetupRestoreTestAssetPackageProjectsInputs;" SetupRestoreTestAssetPackageProjectsInputs;"
Inputs="@(RestoreTestAssetPackageProjectsInputs)" Inputs="@(RestoreTestAssetPackageProjectsInputs)"
Outputs="@(RestoreTestAssetPackageProjectsInputs->'%(RelativeDir)/project.lock.json')"> Outputs="@(RestoreTestAssetPackageProjectsInputs->'%(RelativeDir)/project.lock.json')">
<DotNetRestore ToolPath="$(DotnetUnderTest)" <DotNetRestore ToolPath="$(DotnetUnderTest)"
WorkingDirectory="$(RepoRoot)/TestAssets/TestPackages/" /> WorkingDirectory="$(RepoRoot)/TestAssets/TestPackages/" />
</Target> </Target>

21
build/test/RunTest.proj Normal file
View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTarget="RunTest" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- workaround for https://github.com/Microsoft/msbuild/issues/885 -->
<PropertyGroup>
<CLIBuildDll Condition=" '!Exists($(CLIBuildDll))' ">$([MSBuild]::Unescape($(CLIBuildDll)))</CLIBuildDll>
</PropertyGroup>
<UsingTask TaskName="DotNetTest" AssemblyFile="$(CLIBuildDll)" />
<Target Name="RunTest">
<DotNetTest WorkingDirectory="$(WorkingDirectory)"
EnvironmentVariables="$(EnvironmentVariables)"
ToolPath="$(ToolPath)"
Configuration="$(Configuration)"
NoBuild="True"
NoTrait="category=failing"
Xml="$(TestResultXmlDir)/$(TestProjectName)-testResults.xml" />
</Target>
</Project>

View file

@ -8,7 +8,7 @@
"NETStandard.Library": "1.6.0", "NETStandard.Library": "1.6.0",
"System.Diagnostics.Process": "4.1.0", "System.Diagnostics.Process": "4.1.0",
"System.Reflection.TypeExtensions": "4.1.0", "System.Reflection.TypeExtensions": "4.1.0",
"Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000914" "Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000919"
}, },
"frameworks": { "frameworks": {
"netstandard1.5": { "netstandard1.5": {

View file

@ -16,14 +16,14 @@
"Microsoft.NETCore.Runtime.CoreCLR": "1.0.2", "Microsoft.NETCore.Runtime.CoreCLR": "1.0.2",
"Microsoft.CSharp": "4.0.1", "Microsoft.CSharp": "4.0.1",
"System.Dynamic.Runtime": "4.0.11", "System.Dynamic.Runtime": "4.0.11",
"System.Reflection.Metadata": "1.3.0", "System.Reflection.Metadata": "1.4.1-beta-24410-02",
"System.Runtime.Serialization.Primitives": "4.1.1", "System.Runtime.Serialization.Primitives": "4.1.1",
"System.Xml.XmlSerializer": "4.0.11", "System.Xml.XmlSerializer": "4.0.11",
"WindowsAzure.Storage": "6.2.2-preview", "WindowsAzure.Storage": "6.2.2-preview",
"NuGet.CommandLine.XPlat": "3.6.0-beta.1.msbuild.1", "NuGet.CommandLine.XPlat": "3.6.0-beta.1.msbuild.1",
"Microsoft.Build.Framework": "0.1.0-preview-00029-160805", "Microsoft.Build.Framework": "0.1.0-preview-00029-160805",
"Microsoft.Build.Utilities.Core": "0.1.0-preview-00029-160805", "Microsoft.Build.Utilities.Core": "0.1.0-preview-00029-160805",
"Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000914" "Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000919"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -5,14 +5,14 @@
"NETStandard.Library": "1.6.0", "NETStandard.Library": "1.6.0",
"Microsoft.CSharp": "4.0.1", "Microsoft.CSharp": "4.0.1",
"System.Dynamic.Runtime": "4.0.11", "System.Dynamic.Runtime": "4.0.11",
"System.Reflection.Metadata": "1.3.0", "System.Reflection.Metadata": "1.4.1-beta-24410-02",
"System.Runtime.Serialization.Primitives": "4.1.1", "System.Runtime.Serialization.Primitives": "4.1.1",
"System.Xml.XmlSerializer": "4.0.11", "System.Xml.XmlSerializer": "4.0.11",
"WindowsAzure.Storage": "6.2.2-preview", "WindowsAzure.Storage": "6.2.2-preview",
"Microsoft.DotNet.Cli.Build.Framework": { "Microsoft.DotNet.Cli.Build.Framework": {
"target": "project" "target": "project"
}, },
"Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000914" "Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000919"
}, },
"frameworks": { "frameworks": {
"netstandard1.6": { "netstandard1.6": {

View file

@ -71,10 +71,10 @@ $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
if ($NoBuild) if ($NoBuild)
{ {
Write-Host "Not building due to --nobuild" Write-Host "Not building due to --nobuild"
Write-Host "Command that would be run: 'dotnet build3 build.proj /p:Architecture=$Architecture $ExtraParameters'" Write-Host "Command that would be run: 'dotnet build3 build.proj /m /p:Architecture=$Architecture $ExtraParameters'"
} }
else else
{ {
dotnet build3 build.proj /p:Architecture=$Architecture $ExtraParameters dotnet build3 build.proj /m /p:Architecture=$Architecture $ExtraParameters
if($LASTEXITCODE -ne 0) { throw "Failed to build" } if($LASTEXITCODE -ne 0) { throw "Failed to build" }
} }

View file

@ -117,8 +117,8 @@ export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
echo "${args[@]}" echo "${args[@]}"
if [ $BUILD -eq 1 ]; then if [ $BUILD -eq 1 ]; then
dotnet build3 build.proj /p:Architecture=$ARCHITECTURE "${args[@]}" dotnet build3 build.proj /m /p:Architecture=$ARCHITECTURE "${args[@]}"
else else
echo "Not building due to --nobuild" echo "Not building due to --nobuild"
echo "Command that would be run is: 'dotnet build3 build.proj /p:Architecture=$ARCHITECTURE ${args[@]}'" echo "Command that would be run is: 'dotnet build3 build.proj /m /p:Architecture=$ARCHITECTURE ${args[@]}'"
fi fi

View file

@ -8,7 +8,7 @@
"Microsoft.DotNet.ProjectModel": { "Microsoft.DotNet.ProjectModel": {
"target": "project" "target": "project"
}, },
"Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000914", "Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000919",
"NuGet.Versioning": "3.6.0-beta.1.msbuild.1", "NuGet.Versioning": "3.6.0-beta.1.msbuild.1",
"NuGet.Packaging": "3.6.0-beta.1.msbuild.1", "NuGet.Packaging": "3.6.0-beta.1.msbuild.1",
"NuGet.Frameworks": "3.6.0-beta.1.msbuild.1", "NuGet.Frameworks": "3.6.0-beta.1.msbuild.1",

View file

@ -11,7 +11,7 @@
"target": "project" "target": "project"
}, },
"Microsoft.CodeAnalysis.CSharp.Workspaces": "1.3.0", "Microsoft.CodeAnalysis.CSharp.Workspaces": "1.3.0",
"Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000914" "Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000919"
}, },
"frameworks": { "frameworks": {
"net451": { "net451": {

View file

@ -146,8 +146,8 @@ namespace Microsoft.Extensions.DependencyModel
export.NativeLibraryGroups.Select(CreateRuntimeAssetGroup).ToArray(), export.NativeLibraryGroups.Select(CreateRuntimeAssetGroup).ToArray(),
export.ResourceAssemblies.Select(CreateResourceAssembly), export.ResourceAssemblies.Select(CreateResourceAssembly),
libraryDependencies, libraryDependencies,
serviceable serviceable,
); GetLibraryPath(export.Library));
} }
else else
{ {
@ -168,10 +168,28 @@ namespace Microsoft.Extensions.DependencyModel
export.Library.Hash, export.Library.Hash,
assemblies, assemblies,
libraryDependencies, libraryDependencies,
serviceable); serviceable,
GetLibraryPath(export.Library));
} }
} }
private string GetLibraryPath(LibraryDescription description)
{
var packageDescription = description as PackageDescription;
if (packageDescription != null)
{
// This is the relative path appended to a NuGet packages directory to find the directory containing
// the package assets. This string should mastered only byNuGet, but has the format:
// {lowercase-package-ID}/{lowercase-package-version}
//
// For example: newtonsoft.json/9.0.1
return packageDescription.PackageLibrary?.Path;
}
return null;
}
private RuntimeAssetGroup CreateRuntimeAssetGroup(LibraryAssetGroup libraryAssetGroup) private RuntimeAssetGroup CreateRuntimeAssetGroup(LibraryAssetGroup libraryAssetGroup)
{ {
return new RuntimeAssetGroup( return new RuntimeAssetGroup(

View file

@ -17,5 +17,7 @@ namespace Microsoft.DotNet.ProjectModel.Graph
public string Sha512 { get; set; } public string Sha512 { get; set; }
public IList<string> Files { get; set; } = new List<string>(); public IList<string> Files { get; set; } = new List<string>();
public string Path { get; set; }
} }
} }

View file

@ -144,6 +144,9 @@ namespace Microsoft.DotNet.ProjectModel.Graph
var type = _symbols.GetString(value.Value<string>("type")); var type = _symbols.GetString(value.Value<string>("type"));
var pathValue = value["path"];
var path = pathValue == null ? null : ReadString(pathValue);
if (type == null || string.Equals(type, "package", StringComparison.OrdinalIgnoreCase)) if (type == null || string.Equals(type, "package", StringComparison.OrdinalIgnoreCase))
{ {
lockFile.PackageLibraries.Add(new LockFilePackageLibrary lockFile.PackageLibraries.Add(new LockFilePackageLibrary
@ -152,7 +155,8 @@ namespace Microsoft.DotNet.ProjectModel.Graph
Version = version, Version = version,
IsServiceable = ReadBool(value, "serviceable", defaultValue: false), IsServiceable = ReadBool(value, "serviceable", defaultValue: false),
Sha512 = ReadString(value["sha512"]), Sha512 = ReadString(value["sha512"]),
Files = ReadPathArray(value["files"], ReadString) Files = ReadPathArray(value["files"], ReadString),
Path = path
}); });
} }
else if (type == "project") else if (type == "project")
@ -162,9 +166,8 @@ namespace Microsoft.DotNet.ProjectModel.Graph
Name = name, Name = name,
Version = version Version = version
}; };
var pathValue = value["path"]; projectLibrary.Path = path;
projectLibrary.Path = pathValue == null ? null : ReadString(pathValue);
var buildTimeDependencyValue = value["msbuildProject"]; var buildTimeDependencyValue = value["msbuildProject"];
projectLibrary.MSBuildProject = buildTimeDependencyValue == null ? null : ReadString(buildTimeDependencyValue); projectLibrary.MSBuildProject = buildTimeDependencyValue == null ? null : ReadString(buildTimeDependencyValue);

View file

@ -2,7 +2,6 @@
// 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 System.Linq;
using Microsoft.DotNet.ProjectModel.Graph; using Microsoft.DotNet.ProjectModel.Graph;
namespace Microsoft.DotNet.ProjectModel namespace Microsoft.DotNet.ProjectModel

View file

@ -19,7 +19,8 @@ namespace Microsoft.DotNet.ProjectModel
framework: null, framework: null,
resolved: false, resolved: false,
compatible: false) compatible: false)
{ } {
}
public ProjectDescription( public ProjectDescription(
LibraryRange libraryRange, LibraryRange libraryRange,

View file

@ -5,13 +5,13 @@
}, },
"description": "Types to model a .NET Project", "description": "Types to model a .NET Project",
"dependencies": { "dependencies": {
"Microsoft.Extensions.DependencyModel": "1.0.1-beta-000914", "Microsoft.Extensions.DependencyModel": "1.0.1-beta-000919",
"Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000914", "Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000919",
"Newtonsoft.Json": "9.0.1", "Newtonsoft.Json": "9.0.1",
"NuGet.Configuration": "3.6.0-beta.1.msbuild.1", "NuGet.Configuration": "3.6.0-beta.1.msbuild.1",
"NuGet.Packaging": "3.6.0-beta.1.msbuild.1", "NuGet.Packaging": "3.6.0-beta.1.msbuild.1",
"NuGet.RuntimeModel": "3.6.0-beta.1.msbuild.1", "NuGet.RuntimeModel": "3.6.0-beta.1.msbuild.1",
"System.Reflection.Metadata": "1.3.0" "System.Reflection.Metadata": "1.4.1-beta-24410-02"
}, },
"frameworks": { "frameworks": {
"net451": { "net451": {

View file

@ -12,7 +12,8 @@
"target": "project" "target": "project"
}, },
"Microsoft.DiaSymReader": "1.0.8", "Microsoft.DiaSymReader": "1.0.8",
"Microsoft.DiaSymReader.Native": "1.4.0-rc2" "Microsoft.DiaSymReader.Native": "1.4.0-rc2",
"System.Reflection.Metadata": "1.4.1-beta-24410-02"
}, },
"frameworks": { "frameworks": {
"net451": {}, "net451": {},

View file

@ -15,7 +15,7 @@ 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;
using Microsoft.DotNet.Tools.New; using Microsoft.DotNet.Tools.New;
using Microsoft.DotNet.Tools.NuGet; using Microsoft.DotNet.Tools.Pack3;
using Microsoft.DotNet.Tools.Publish; using Microsoft.DotNet.Tools.Publish;
using Microsoft.DotNet.Tools.Restore; using Microsoft.DotNet.Tools.Restore;
using Microsoft.DotNet.Tools.Restore3; using Microsoft.DotNet.Tools.Restore3;
@ -42,6 +42,7 @@ namespace Microsoft.DotNet.Cli
["build3"] = Build3Command.Run, ["build3"] = Build3Command.Run,
["run3"] = Run3Command.Run, ["run3"] = Run3Command.Run,
["restore3"] = Restore3Command.Run, ["restore3"] = Restore3Command.Run,
["pack3"] = Pack3Command.Run,
}; };
public static int Main(string[] args) public static int Main(string[] args)

View file

@ -6,7 +6,7 @@
"dependencies": { "dependencies": {
"System.Runtime.Serialization.Primitives": "4.1.1", "System.Runtime.Serialization.Primitives": "4.1.1",
"xunit": "2.1.0", "xunit": "2.1.0",
"dotnet-test-xunit": "1.0.0-rc2-192208-24", "dotnet-test-xunit": "1.0.0-rc2-330423-54",
"Microsoft.DotNet.InternalAbstractions": "1.0.0" "Microsoft.DotNet.InternalAbstractions": "1.0.0"
}, },
"testRunner": "xunit", "testRunner": "xunit",

View file

@ -0,0 +1,87 @@
// 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 Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Utils;
namespace Microsoft.DotNet.Tools.Pack3
{
public class Pack3Command
{
public static int Run(string[] args)
{
DebugHelper.HandleDebugSwitch(ref args);
CommandLineApplication cmd = new CommandLineApplication(throwOnUnexpectedArg: false)
{
Name = "pack3",
FullName = "pack3",
Description = "pack for msbuild"
};
cmd.HelpOption("-h|--help");
var output = cmd.Option("-o|--output <OUTPUT_DIR>",
"Directory in which to place outputs",
CommandOptionType.SingleValue);
var noBuild = cmd.Option("--no-build",
"Do not build project before packing",
CommandOptionType.NoValue);
var configuration = cmd.Option("-c|--configuration <CONFIGURATION>",
"Configuration under which to build",
CommandOptionType.SingleValue);
var versionSuffix = cmd.Option("--version-suffix <VERSION_SUFFIX>",
"Defines what `*` should be replaced with in version field in project.json",
CommandOptionType.SingleValue);
var serviceable = cmd.Option("-s|--serviceable",
"Set the serviceable flag in the package",
CommandOptionType.NoValue);
var argRoot = cmd.Argument("<PROJECT>",
"The project to pack, defaults to the project file in the current directory. Can be a path to any project file",
multipleValues:true);
cmd.OnExecute(() =>
{
var msbuildArgs = new List<string>()
{
"/t:pack"
};
if (noBuild.HasValue())
{
msbuildArgs.Add($"/p:NoBuild=true");
}
if (output.HasValue())
{
msbuildArgs.Add($"/p:PackageOutputPath={output.Value()}");
}
if (configuration.HasValue())
{
msbuildArgs.Add($"/p:Configuration={configuration.Value()}");
}
if (versionSuffix.HasValue())
{
msbuildArgs.Add($"/p:VersionSuffix={versionSuffix.Value()}");
}
if (serviceable.HasValue())
{
msbuildArgs.Add($"/p:Serviceable=true");
}
msbuildArgs.AddRange(argRoot.Values);
msbuildArgs.AddRange(cmd.RemainingArguments);
return new MSBuildForwardingApp(msbuildArgs).Execute();
});
return cmd.Execute(args);
}
}
}

View file

@ -65,7 +65,7 @@
"Microsoft.Build": "0.1.0-preview-00029-160805", "Microsoft.Build": "0.1.0-preview-00029-160805",
"Microsoft.Build.Framework": "0.1.0-preview-00029-160805", "Microsoft.Build.Framework": "0.1.0-preview-00029-160805",
"Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000914" "Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000919"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -19,8 +19,8 @@
"target": "project" "target": "project"
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21", "dotnet-test-xunit": "1.0.0-rc2-330423-54",
"Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000914" "Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000919"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -20,8 +20,8 @@
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"xunit.netcore.extensions": "1.0.0-prerelease-00206", "xunit.netcore.extensions": "1.0.0-prerelease-00206",
"dotnet-test-xunit": "1.0.0-rc2-318883-21", "dotnet-test-xunit": "1.0.0-rc2-330423-54",
"Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000914" "Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000919"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -13,7 +13,7 @@
"target": "project" "target": "project"
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21" "dotnet-test-xunit": "1.0.0-rc2-330423-54"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -21,7 +21,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
var configuration = "Debug"; var configuration = "Debug";
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects")); var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects"));
var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDependencyDesktopAndPortable") var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDepDesktopAndPortable")
.WithLockFiles(); .WithLockFiles();
var buildCommand = new BuildCommand( var buildCommand = new BuildCommand(
@ -52,7 +52,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
var configuration = "Debug"; var configuration = "Debug";
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects")); var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects"));
var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDependencyDesktopAndPortable") var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDepDesktopAndPortable")
.WithLockFiles(); .WithLockFiles();
var buildCommand = new BuildCommand( var buildCommand = new BuildCommand(
@ -83,7 +83,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
var configuration = "Release"; var configuration = "Release";
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects")); var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects"));
var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDependencyDesktopAndPortable") var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDepDesktopAndPortable")
.WithLockFiles(); .WithLockFiles();
var buildCommand = new BuildCommand( var buildCommand = new BuildCommand(
@ -114,7 +114,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
var configuration = "Release"; var configuration = "Release";
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects")); var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects"));
var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDependencyDesktopAndPortable") var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDepDesktopAndPortable")
.WithLockFiles(); .WithLockFiles();
var buildCommand = new BuildCommand( var buildCommand = new BuildCommand(
@ -145,7 +145,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
var configuration = "Debug"; var configuration = "Debug";
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "TestProjects")); var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "TestProjects"));
var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDependencyWithOutputName") var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDepWithOutputName")
.WithLockFiles(); .WithLockFiles();
var buildCommand = new BuildCommand( var buildCommand = new BuildCommand(

View file

@ -12,11 +12,10 @@ using Xunit;
namespace Microsoft.DotNet.Cli.Utils.Tests namespace Microsoft.DotNet.Cli.Utils.Tests
{ {
public class GivenAProjectDependenciesCommandResolver public class GivenAProjectDependenciesCommandResolver : TestBase
{ {
private static readonly string s_liveProjectDirectory = private const string TestProjectName = "AppWithDirectDep";
Path.Combine(AppContext.BaseDirectory, "TestAssets/TestProjects/AppWithDirectDependency");
[Fact] [Fact]
public void It_returns_null_when_CommandName_is_null() public void It_returns_null_when_CommandName_is_null()
@ -61,11 +60,14 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
{ {
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver(); var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
.WithLockFiles();
var commandResolverArguments = new CommandResolverArguments() var commandResolverArguments = new CommandResolverArguments()
{ {
CommandName = "command", CommandName = "command",
CommandArguments = new string[] { "" }, CommandArguments = new string[] { "" },
ProjectDirectory = s_liveProjectDirectory, ProjectDirectory = testInstance.Path,
Configuration = "Debug", Configuration = "Debug",
Framework = null Framework = null
}; };
@ -80,11 +82,14 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
{ {
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver(); var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
.WithLockFiles();
var commandResolverArguments = new CommandResolverArguments() var commandResolverArguments = new CommandResolverArguments()
{ {
CommandName = "command", CommandName = "command",
CommandArguments = new string[] { "" }, CommandArguments = new string[] { "" },
ProjectDirectory = s_liveProjectDirectory, ProjectDirectory = testInstance.Path,
Configuration = null, Configuration = null,
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10 Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10
}; };
@ -99,11 +104,14 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
{ {
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver(); var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
.WithLockFiles();
var commandResolverArguments = new CommandResolverArguments() var commandResolverArguments = new CommandResolverArguments()
{ {
CommandName = "nonexistent-command", CommandName = "nonexistent-command",
CommandArguments = null, CommandArguments = null,
ProjectDirectory = s_liveProjectDirectory, ProjectDirectory = testInstance.Path,
Configuration = "Debug", Configuration = "Debug",
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10 Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10
}; };
@ -118,11 +126,15 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
{ {
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver(); var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
.WithBuildArtifacts()
.WithLockFiles();
var commandResolverArguments = new CommandResolverArguments() var commandResolverArguments = new CommandResolverArguments()
{ {
CommandName = "dotnet-hello", CommandName = "dotnet-hello",
CommandArguments = null, CommandArguments = null,
ProjectDirectory = s_liveProjectDirectory, ProjectDirectory = testInstance.Path,
Configuration = "Debug", Configuration = "Debug",
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10 Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10
}; };
@ -143,11 +155,15 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
{ {
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver(); var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
.WithBuildArtifacts()
.WithLockFiles();
var commandResolverArguments = new CommandResolverArguments() var commandResolverArguments = new CommandResolverArguments()
{ {
CommandName = "dotnet-hello", CommandName = "dotnet-hello",
CommandArguments = new[] { "arg with space" }, CommandArguments = new[] { "arg with space" },
ProjectDirectory = s_liveProjectDirectory, ProjectDirectory = testInstance.Path,
Configuration = "Debug", Configuration = "Debug",
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10 Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10
}; };
@ -159,15 +175,19 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
} }
[Fact] [Fact]
public void It_passes_depsfile_arg_to_host_when_returning_a_commandspec() public void It_passes_depsfile_arg_to_host_when_returning_a_CommandSpec()
{ {
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver(); var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
.WithBuildArtifacts()
.WithLockFiles();
var commandResolverArguments = new CommandResolverArguments() var commandResolverArguments = new CommandResolverArguments()
{ {
CommandName = "dotnet-hello", CommandName = "dotnet-hello",
CommandArguments = null, CommandArguments = null,
ProjectDirectory = s_liveProjectDirectory, ProjectDirectory = testInstance.Path,
Configuration = "Debug", Configuration = "Debug",
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10 Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10
}; };
@ -182,26 +202,30 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
public void It_sets_depsfile_in_output_path_in_commandspec() public void It_sets_depsfile_in_output_path_in_commandspec()
{ {
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver(); var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
var outputDir = Path.Combine(AppContext.BaseDirectory, "outdir");
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
.WithLockFiles();
var outputDir = Path.Combine(testInstance.Path, "outdir");
var commandResolverArguments = new CommandResolverArguments var commandResolverArguments = new CommandResolverArguments
{ {
CommandName = "dotnet-hello", CommandName = "dotnet-hello",
CommandArguments = null, CommandArguments = null,
ProjectDirectory = s_liveProjectDirectory, ProjectDirectory = testInstance.Path,
Configuration = "Debug", Configuration = "Debug",
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10, Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10,
OutputPath = outputDir OutputPath = outputDir
}; };
var buildCommand = new BuildCommand( var buildCommand = new BuildCommand(
Path.Combine(s_liveProjectDirectory, "project.json"), Path.Combine(testInstance.Path, "project.json"),
output: outputDir, output: outputDir,
framework: FrameworkConstants.CommonFrameworks.NetCoreApp10.ToString()) framework: FrameworkConstants.CommonFrameworks.NetCoreApp10.ToString())
.Execute().Should().Pass(); .Execute().Should().Pass();
var projectContext = ProjectContext.Create( var projectContext = ProjectContext.Create(
s_liveProjectDirectory, testInstance.Path,
FrameworkConstants.CommonFrameworks.NetCoreApp10, FrameworkConstants.CommonFrameworks.NetCoreApp10,
RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers()); RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers());
@ -218,26 +242,30 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
public void It_sets_depsfile_in_build_base_path_in_commandspec() public void It_sets_depsfile_in_build_base_path_in_commandspec()
{ {
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver(); var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
var buildBasePath = Path.Combine(AppContext.BaseDirectory, "basedir");
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
.WithLockFiles();
var buildBasePath = Path.Combine(testInstance.Path, "basedir");
var commandResolverArguments = new CommandResolverArguments var commandResolverArguments = new CommandResolverArguments
{ {
CommandName = "dotnet-hello", CommandName = "dotnet-hello",
CommandArguments = null, CommandArguments = null,
ProjectDirectory = s_liveProjectDirectory, ProjectDirectory = testInstance.Path,
Configuration = "Debug", Configuration = "Debug",
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10, Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10,
BuildBasePath = buildBasePath BuildBasePath = buildBasePath
}; };
var buildCommand = new BuildCommand( var buildCommand = new BuildCommand(
Path.Combine(s_liveProjectDirectory, "project.json"), Path.Combine(testInstance.Path, "project.json"),
buildBasePath: buildBasePath, buildBasePath: buildBasePath,
framework: FrameworkConstants.CommonFrameworks.NetCoreApp10.ToString()) framework: FrameworkConstants.CommonFrameworks.NetCoreApp10.ToString())
.Execute().Should().Pass(); .Execute().Should().Pass();
var projectContext = ProjectContext.Create( var projectContext = ProjectContext.Create(
s_liveProjectDirectory, testInstance.Path,
FrameworkConstants.CommonFrameworks.NetCoreApp10, FrameworkConstants.CommonFrameworks.NetCoreApp10,
RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers()); RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers());
@ -255,11 +283,15 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
{ {
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver(); var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
.WithBuildArtifacts()
.WithLockFiles();
var commandResolverArguments = new CommandResolverArguments() var commandResolverArguments = new CommandResolverArguments()
{ {
CommandName = "dotnet-hello", CommandName = "dotnet-hello",
CommandArguments = null, CommandArguments = null,
ProjectDirectory = s_liveProjectDirectory, ProjectDirectory = testInstance.Path,
Configuration = "Debug", Configuration = "Debug",
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10 Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10
}; };

View file

@ -7,6 +7,7 @@ using System.Linq;
using FluentAssertions; using FluentAssertions;
using Microsoft.DotNet.ProjectModel; using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.ProjectModel.Graph; using Microsoft.DotNet.ProjectModel.Graph;
using Microsoft.DotNet.TestFramework;
using Microsoft.DotNet.Tools.Test.Utilities; using Microsoft.DotNet.Tools.Test.Utilities;
using NuGet.Frameworks; using NuGet.Frameworks;
using NuGet.Versioning; using NuGet.Versioning;
@ -14,12 +15,11 @@ using Xunit;
namespace Microsoft.DotNet.Cli.Utils.Tests namespace Microsoft.DotNet.Cli.Utils.Tests
{ {
public class GivenAProjectToolsCommandResolver public class GivenAProjectToolsCommandResolver : TestBase
{ {
private static readonly NuGetFramework s_toolPackageFramework = FrameworkConstants.CommonFrameworks.NetCoreApp10; private static readonly NuGetFramework s_toolPackageFramework = FrameworkConstants.CommonFrameworks.NetCoreApp10;
private static readonly string s_liveProjectDirectory = private const string TestProjectName = "AppWithToolDependency";
Path.Combine(AppContext.BaseDirectory, "TestAssets/TestProjects/AppWithToolDependency");
[Fact] [Fact]
public void It_returns_null_when_CommandName_is_null() public void It_returns_null_when_CommandName_is_null()
@ -60,11 +60,14 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
{ {
var projectToolsCommandResolver = SetupProjectToolsCommandResolver(); var projectToolsCommandResolver = SetupProjectToolsCommandResolver();
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
.WithLockFiles();
var commandResolverArguments = new CommandResolverArguments() var commandResolverArguments = new CommandResolverArguments()
{ {
CommandName = "nonexistent-command", CommandName = "nonexistent-command",
CommandArguments = null, CommandArguments = null,
ProjectDirectory = s_liveProjectDirectory ProjectDirectory = testInstance.Path
}; };
var result = projectToolsCommandResolver.Resolve(commandResolverArguments); var result = projectToolsCommandResolver.Resolve(commandResolverArguments);
@ -77,11 +80,14 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
{ {
var projectToolsCommandResolver = SetupProjectToolsCommandResolver(); var projectToolsCommandResolver = SetupProjectToolsCommandResolver();
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
.WithLockFiles();
var commandResolverArguments = new CommandResolverArguments() var commandResolverArguments = new CommandResolverArguments()
{ {
CommandName = "dotnet-portable", CommandName = "dotnet-portable",
CommandArguments = null, CommandArguments = null,
ProjectDirectory = s_liveProjectDirectory ProjectDirectory = testInstance.Path
}; };
var result = projectToolsCommandResolver.Resolve(commandResolverArguments); var result = projectToolsCommandResolver.Resolve(commandResolverArguments);
@ -100,11 +106,14 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
{ {
var projectToolsCommandResolver = SetupProjectToolsCommandResolver(); var projectToolsCommandResolver = SetupProjectToolsCommandResolver();
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
.WithLockFiles();
var commandResolverArguments = new CommandResolverArguments() var commandResolverArguments = new CommandResolverArguments()
{ {
CommandName = "dotnet-portable", CommandName = "dotnet-portable",
CommandArguments = new[] { "arg with space" }, CommandArguments = new[] { "arg with space" },
ProjectDirectory = s_liveProjectDirectory ProjectDirectory = testInstance.Path
}; };
var result = projectToolsCommandResolver.Resolve(commandResolverArguments); var result = projectToolsCommandResolver.Resolve(commandResolverArguments);
@ -118,11 +127,14 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
{ {
var projectToolsCommandResolver = SetupProjectToolsCommandResolver(); var projectToolsCommandResolver = SetupProjectToolsCommandResolver();
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
.WithLockFiles();
var commandResolverArguments = new CommandResolverArguments() var commandResolverArguments = new CommandResolverArguments()
{ {
CommandName = "dotnet-portable", CommandName = "dotnet-portable",
CommandArguments = null, CommandArguments = null,
ProjectDirectory = s_liveProjectDirectory ProjectDirectory = testInstance.Path
}; };
var result = projectToolsCommandResolver.Resolve(commandResolverArguments); var result = projectToolsCommandResolver.Resolve(commandResolverArguments);
@ -138,14 +150,17 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
{ {
var projectToolsCommandResolver = SetupProjectToolsCommandResolver(); var projectToolsCommandResolver = SetupProjectToolsCommandResolver();
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
.WithLockFiles();
var commandResolverArguments = new CommandResolverArguments() var commandResolverArguments = new CommandResolverArguments()
{ {
CommandName = "dotnet-portable", CommandName = "dotnet-portable",
CommandArguments = null, CommandArguments = null,
ProjectDirectory = s_liveProjectDirectory ProjectDirectory = testInstance.Path
}; };
var context = ProjectContext.Create(Path.Combine(s_liveProjectDirectory, "project.json"), s_toolPackageFramework); var context = ProjectContext.Create(Path.Combine(testInstance.Path, "project.json"), s_toolPackageFramework);
var nugetPackagesRoot = context.PackagesDirectory; var nugetPackagesRoot = context.PackagesDirectory;
var toolPathCalculator = new ToolPathCalculator(nugetPackagesRoot); var toolPathCalculator = new ToolPathCalculator(nugetPackagesRoot);
@ -180,7 +195,10 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
[Fact] [Fact]
public void Generate_deps_json_method_doesnt_overwrite_when_deps_file_already_exists() public void Generate_deps_json_method_doesnt_overwrite_when_deps_file_already_exists()
{ {
var context = ProjectContext.Create(Path.Combine(s_liveProjectDirectory, "project.json"), s_toolPackageFramework); var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
.WithLockFiles();
var context = ProjectContext.Create(Path.Combine(testInstance.Path, "project.json"), s_toolPackageFramework);
var nugetPackagesRoot = context.PackagesDirectory; var nugetPackagesRoot = context.PackagesDirectory;
var toolPathCalculator = new ToolPathCalculator(nugetPackagesRoot); var toolPathCalculator = new ToolPathCalculator(nugetPackagesRoot);

View file

@ -14,20 +14,12 @@ namespace StreamForwarderTests
public class StreamForwarderTests : TestBase public class StreamForwarderTests : TestBase
{ {
private static readonly string s_rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier(); private static readonly string s_rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier();
private static readonly string s_testProjectRoot = Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects");
private TempDirectory _root;
public static void Main() public static void Main()
{ {
Console.WriteLine("Dummy Entrypoint"); Console.WriteLine("Dummy Entrypoint");
} }
public StreamForwarderTests()
{
_root = Temp.CreateDirectory();
}
public static IEnumerable<object[]> ForwardingTheoryVariations public static IEnumerable<object[]> ForwardingTheoryVariations
{ {
get get
@ -127,15 +119,15 @@ namespace StreamForwarderTests
private string SetupTestProject() private string SetupTestProject()
{ {
var sourceTestProjectPath = Path.Combine(s_testProjectRoot, "OutputStandardOutputAndError");
var binTestProjectPath = _root.CopyDirectory(sourceTestProjectPath).Path; var testInstance = TestAssetsManager.CreateTestInstance("OutputStandardOutputAndError")
.WithLockFiles();
var buildCommand = new BuildCommand(Path.Combine(binTestProjectPath, "project.json")); var buildCommand = new BuildCommand(Path.Combine(testInstance.Path, "project.json"));
buildCommand.Execute(); buildCommand.Execute();
var buildOutputExe = "OutputStandardOutputAndError" + Constants.ExeSuffix; var buildOutputExe = "OutputStandardOutputAndError" + Constants.ExeSuffix;
var buildOutputPath = Path.Combine(binTestProjectPath, "bin/Debug/netcoreapp1.0", buildOutputExe); var buildOutputPath = Path.Combine(testInstance.Path, "bin/Debug/netcoreapp1.0", buildOutputExe);
return buildOutputPath; return buildOutputPath;
} }

View file

@ -35,8 +35,8 @@
}, },
"moq.netcore": "4.4.0-beta8", "moq.netcore": "4.4.0-beta8",
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21", "dotnet-test-xunit": "1.0.0-rc2-330423-54",
"Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000914" "Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000919"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -16,7 +16,7 @@
"target": "project" "target": "project"
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21" "dotnet-test-xunit": "1.0.0-rc2-330423-54"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -21,7 +21,7 @@
"FluentAssertions": "4.0.0", "FluentAssertions": "4.0.0",
"moq.netcore": "4.4.0-beta8", "moq.netcore": "4.4.0-beta8",
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21" "dotnet-test-xunit": "1.0.0-rc2-330423-54"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -15,7 +15,7 @@
"target": "project" "target": "project"
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21" "dotnet-test-xunit": "1.0.0-rc2-330423-54"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -7,24 +7,18 @@ namespace Microsoft.DotNet.ProjectModel.Tests
{ {
public class LibraryExporterTests : TestBase public class LibraryExporterTests : TestBase
{ {
private readonly string _testProjectsRoot;
public LibraryExporterTests()
{
_testProjectsRoot = Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects");
}
[Fact] [Fact]
public void GetLibraryExportsWithoutLockFile() public void GetLibraryExportsWithoutLockFile()
{ {
var root = Temp.CreateDirectory().CopyDirectory(Path.Combine(_testProjectsRoot, "TestAppWithLibrary"));
foreach (var lockfile in Directory.GetFiles(root.Path, "project.lock.json")) var testInstance = TestAssetsManager.CreateTestInstance("TestAppWithLibrary");
foreach (var lockfile in Directory.GetFiles(testInstance.Path, "project.lock.json"))
{ {
File.Delete(lockfile); File.Delete(lockfile);
} }
var builder = new ProjectContextBuilder().WithProjectDirectory(Path.Combine(root.Path, "TestApp")); var builder = new ProjectContextBuilder().WithProjectDirectory(Path.Combine(testInstance.Path, "TestApp"));
foreach (var context in builder.BuildAllTargets()) foreach (var context in builder.BuildAllTargets())
{ {

View file

@ -0,0 +1,120 @@
// 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.IO;
using System.Linq;
using System.Text;
using FluentAssertions;
using Microsoft.DotNet.ProjectModel.Graph;
using Microsoft.DotNet.Tools.Test.Utilities;
using Xunit;
namespace Microsoft.DotNet.ProjectModel.Tests
{
public class LockFileReaderTests : TestBase
{
[Fact]
public void ReadsAllLibraryPropertiesWhenPathIsPresent()
{
// Arrange
var lockFileJson = @"
{
""libraries"": {
""PackageA/1.0.1-Alpha"": {
""sha512"": ""FAKE-HASH"",
""type"": ""package"",
""serviceable"": true,
""files"": [
""a.txt"",
""foo/b.txt""
],
""path"": ""PackageA/1.0.1-beta-PATH""
},
""ProjectA/1.0.2-Beta"": {
""type"": ""project"",
""path"": ""ProjectA-PATH"",
""msbuildProject"": ""some-msbuild""
}
}
}";
var lockFileStream = new MemoryStream(Encoding.UTF8.GetBytes(lockFileJson));
var lockFileReader = new LockFileReader();
// Act
var lockFile = lockFileReader.ReadLockFile(
lockFilePath: null,
stream: lockFileStream,
designTime: true);
// Assert
lockFile.PackageLibraries.Should().HaveCount(1);
var package = lockFile.PackageLibraries.First();
package.Name.Should().Be("PackageA");
package.Version.ToString().Should().Be("1.0.1-Alpha");
package.Sha512.Should().Be("FAKE-HASH");
package.IsServiceable.Should().BeTrue();
package.Files.Should().HaveCount(2);
package.Files[0].Should().Be("a.txt");
package.Files[1].Should().Be(Path.Combine("foo", "b.txt"));
package.Path.Should().Be("PackageA/1.0.1-beta-PATH");
lockFile.ProjectLibraries.Should().HaveCount(1);
var project = lockFile.ProjectLibraries.First();
project.Name.Should().Be("ProjectA");
project.Version.ToString().Should().Be("1.0.2-Beta");
project.Path.Should().Be("ProjectA-PATH");
}
[Fact]
public void ReadsAllLibraryPropertiesWhenPathIsNotPresent()
{
// Arrange
var lockFileJson = @"
{
""libraries"": {
""PackageA/1.0.1-Alpha"": {
""sha512"": ""FAKE-HASH"",
""type"": ""package"",
""serviceable"": true,
""files"": [
""a.txt"",
""foo/b.txt""
]
},
""ProjectA/1.0.2-Beta"": {
""type"": ""project"",
""msbuildProject"": ""some-msbuild""
}
}
}";
var lockFileStream = new MemoryStream(Encoding.UTF8.GetBytes(lockFileJson));
var lockFileReader = new LockFileReader();
// Act
var lockFile = lockFileReader.ReadLockFile(
lockFilePath: null,
stream: lockFileStream,
designTime: true);
// Assert
lockFile.PackageLibraries.Should().HaveCount(1);
var package = lockFile.PackageLibraries.First();
package.Name.Should().Be("PackageA");
package.Version.ToString().Should().Be("1.0.1-Alpha");
package.Sha512.Should().Be("FAKE-HASH");
package.IsServiceable.Should().BeTrue();
package.Files.Should().HaveCount(2);
package.Files[0].Should().Be("a.txt");
package.Files[1].Should().Be(Path.Combine("foo", "b.txt"));
package.Path.Should().BeNull();
lockFile.ProjectLibraries.Should().HaveCount(1);
var project = lockFile.ProjectLibraries.First();
project.Name.Should().Be("ProjectA");
project.Version.ToString().Should().Be("1.0.2-Beta");
project.Path.Should().BeNull();
}
}
}

View file

@ -1,5 +1,7 @@
using System; using System;
using System.IO;
using System.Linq; using System.Linq;
using FluentAssertions;
using Microsoft.DotNet.ProjectModel.Graph; using Microsoft.DotNet.ProjectModel.Graph;
using Microsoft.DotNet.ProjectModel.Resolution; using Microsoft.DotNet.ProjectModel.Resolution;
using Microsoft.DotNet.TestFramework; using Microsoft.DotNet.TestFramework;
@ -8,16 +10,46 @@ using NuGet.Configuration;
using NuGet.Frameworks; using NuGet.Frameworks;
using NuGet.Versioning; using NuGet.Versioning;
using Xunit; using Xunit;
using System.IO;
namespace Microsoft.DotNet.ProjectModel.Tests namespace Microsoft.DotNet.ProjectModel.Tests
{ {
public class PackageDependencyProviderTests : TestBase public class PackageDependencyProviderTests : TestBase
{ {
[Fact]
public void GetDescriptionShouldLeavePackageLibraryPathAlone()
{
// Arrange
var provider = new PackageDependencyProvider(
NuGetPathContext.Create("/foo/packages"),
new FrameworkReferenceResolver("/foo/references"));
var package = new LockFilePackageLibrary();
package.Name = "Something";
package.Version = NuGetVersion.Parse("1.0.0");
package.Files.Add("lib/dotnet/_._");
package.Files.Add("runtimes/any/native/Microsoft.CSharp.CurrentVersion.targets");
package.Path = "SomePath";
var target = new LockFileTargetLibrary();
target.Name = "Something";
target.Version = package.Version;
target.RuntimeAssemblies.Add("lib/dotnet/_._");
target.CompileTimeAssemblies.Add("lib/dotnet/_._");
target.NativeLibraries.Add("runtimes/any/native/Microsoft.CSharp.CurrentVersion.targets");
// Act
var p = provider.GetDescription(NuGetFramework.Parse("netcoreapp1.0"), package, target);
// Assert
p.PackageLibrary.Path.Should().Be("SomePath");
}
[Fact] [Fact]
public void GetDescriptionShouldNotModifyTarget() public void GetDescriptionShouldNotModifyTarget()
{ {
var provider = new PackageDependencyProvider(NuGetPathContext.Create("/foo/packages"), new FrameworkReferenceResolver("/foo/references")); var provider = new PackageDependencyProvider(
NuGetPathContext.Create("/foo/packages"),
new FrameworkReferenceResolver("/foo/references"));
var package = new LockFilePackageLibrary(); var package = new LockFilePackageLibrary();
package.Name = "Something"; package.Name = "Something";
package.Version = NuGetVersion.Parse("1.0.0"); package.Version = NuGetVersion.Parse("1.0.0");
@ -48,7 +80,9 @@ namespace Microsoft.DotNet.ProjectModel.Tests
[Fact] [Fact]
public void HasCompileTimePlaceholderChecksAllCompileTimeAssets() public void HasCompileTimePlaceholderChecksAllCompileTimeAssets()
{ {
var provider = new PackageDependencyProvider(NuGetPathContext.Create("/foo/packages"), new FrameworkReferenceResolver("/foo/references")); var provider = new PackageDependencyProvider(
NuGetPathContext.Create("/foo/packages"),
new FrameworkReferenceResolver("/foo/references"));
var package = new LockFilePackageLibrary(); var package = new LockFilePackageLibrary();
package.Name = "Something"; package.Name = "Something";
package.Version = NuGetVersion.Parse("1.0.0"); package.Version = NuGetVersion.Parse("1.0.0");
@ -76,7 +110,9 @@ namespace Microsoft.DotNet.ProjectModel.Tests
[Fact] [Fact]
public void HasCompileTimePlaceholderReturnsFalseIfEmpty() public void HasCompileTimePlaceholderReturnsFalseIfEmpty()
{ {
var provider = new PackageDependencyProvider(NuGetPathContext.Create("/foo/packages"), new FrameworkReferenceResolver("/foo/references")); var provider = new PackageDependencyProvider(
NuGetPathContext.Create("/foo/packages"),
new FrameworkReferenceResolver("/foo/references"));
var package = new LockFilePackageLibrary(); var package = new LockFilePackageLibrary();
package.Name = "Something"; package.Name = "Something";
package.Version = NuGetVersion.Parse("1.0.0"); package.Version = NuGetVersion.Parse("1.0.0");

View file

@ -21,7 +21,7 @@
"target": "project" "target": "project"
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21" "dotnet-test-xunit": "1.0.0-rc2-330423-54"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -7,14 +7,14 @@
"dependencies": { "dependencies": {
"FluentAssertions": "4.0.0", "FluentAssertions": "4.0.0",
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21", "dotnet-test-xunit": "1.0.0-rc2-330423-54",
"Microsoft.DotNet.TestFramework": { "target": "project" }, "Microsoft.DotNet.TestFramework": { "target": "project" },
"Microsoft.DotNet.Cli.Utils": { "target": "project" }, "Microsoft.DotNet.Cli.Utils": { "target": "project" },
"Microsoft.DotNet.ProjectModel": { "target": "project" }, "Microsoft.DotNet.ProjectModel": { "target": "project" },
"Microsoft.DotNet.InternalAbstractions": { "Microsoft.DotNet.InternalAbstractions": {
"target": "project" "target": "project"
}, },
"Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000914" "Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000919"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -17,7 +17,7 @@
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"xunit.netcore.extensions": "1.0.0-prerelease-00206", "xunit.netcore.extensions": "1.0.0-prerelease-00206",
"dotnet-test-xunit": "1.0.0-rc2-318883-21", "dotnet-test-xunit": "1.0.0-rc2-330423-54",
"Microsoft.DotNet.xunit.performance": "1.0.0-alpha-build0028" "Microsoft.DotNet.xunit.performance": "1.0.0-alpha-build0028"
}, },
"frameworks": { "frameworks": {

View file

@ -15,7 +15,7 @@
"target": "project" "target": "project"
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21" "dotnet-test-xunit": "1.0.0-rc2-330423-54"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -19,7 +19,7 @@
"target": "project" "target": "project"
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21", "dotnet-test-xunit": "1.0.0-rc2-330423-54",
"FluentAssertions": "4.2.2" "FluentAssertions": "4.2.2"
}, },
"frameworks": { "frameworks": {

View file

@ -14,7 +14,7 @@
"target": "project" "target": "project"
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21", "dotnet-test-xunit": "1.0.0-rc2-330423-54",
"FluentAssertions": "4.2.2", "FluentAssertions": "4.2.2",
"moq.netcore": "4.4.0-beta8" "moq.netcore": "4.4.0-beta8"
}, },

View file

@ -2,7 +2,7 @@
"version": "1.0.0-*", "version": "1.0.0-*",
"dependencies": { "dependencies": {
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21", "dotnet-test-xunit": "1.0.0-rc2-330423-54",
"Microsoft.NETCore.Platforms": "1.0.1", "Microsoft.NETCore.Platforms": "1.0.1",
"Microsoft.DotNet.Tools.Tests.Utilities": { "Microsoft.DotNet.Tools.Tests.Utilities": {
"target": "project" "target": "project"

View file

@ -12,7 +12,7 @@
"target": "project" "target": "project"
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21" "dotnet-test-xunit": "1.0.0-rc2-330423-54"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -10,7 +10,7 @@
"target": "project" "target": "project"
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21" "dotnet-test-xunit": "1.0.0-rc2-330423-54"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -12,7 +12,7 @@
"target": "project" "target": "project"
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21" "dotnet-test-xunit": "1.0.0-rc2-330423-54"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -13,28 +13,18 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
{ {
public class CompilerTests : TestBase public class CompilerTests : TestBase
{ {
private readonly string _testProjectsRoot;
public CompilerTests()
{
_testProjectsRoot = Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects");
}
[Fact] [Fact]
public void XmlDocumentationFileIsGenerated() public void XmlDocumentationFileIsGenerated()
{ {
// create unique directories in the 'temp' folder var testInstance = TestAssetsManager
var root = Temp.CreateDirectory(); .CreateTestInstance("TestAppWithLibrary")
root.CopyFile(Path.Combine(_testProjectsRoot, "global.json")); .WithLockFiles();
var testLibDir = root.CreateDirectory("TestLibrary"); var testLibDir = Path.Combine(testInstance.TestRoot, "TestLibrary");
var sourceTestLibDir = Path.Combine(_testProjectsRoot, "TestAppWithLibrary", "TestLibrary");
CopyProjectToTempDir(sourceTestLibDir, testLibDir);
// run compile // run compile
var outputDir = Path.Combine(testLibDir.Path, "bin"); var outputDir = Path.Combine(testLibDir, "bin");
var testProject = GetProjectPath(testLibDir); var testProject = Path.Combine(testLibDir, "project.json");
var buildCommand = new BuildCommand(testProject, output: outputDir, framework: DefaultLibraryFramework); var buildCommand = new BuildCommand(testProject, output: outputDir, framework: DefaultLibraryFramework);
var result = buildCommand.ExecuteWithCapturedOutput(); var result = buildCommand.ExecuteWithCapturedOutput();
result.Should().Pass(); result.Should().Pass();
@ -49,16 +39,15 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
[Fact] [Fact]
public void SatelliteAssemblyIsGeneratedByDotnetBuild() public void SatelliteAssemblyIsGeneratedByDotnetBuild()
{ {
// create unique directories in the 'temp' folder var testInstance = TestAssetsManager
var root = Temp.CreateDirectory(); .CreateTestInstance("TestProjectWithCultureSpecificResource")
var testLibDir = root.CreateDirectory("TestProjectWithCultureSpecificResource"); .WithLockFiles();
var sourceTestLibDir = Path.Combine(_testProjectsRoot, "TestProjectWithCultureSpecificResource");
CopyProjectToTempDir(sourceTestLibDir, testLibDir); var testLibDir = testInstance.TestRoot;
// run compile on a project with resources // run compile on a project with resources
var outputDir = Path.Combine(testLibDir.Path, "bin"); var outputDir = Path.Combine(testLibDir, "bin");
var testProject = GetProjectPath(testLibDir); var testProject = Path.Combine(testLibDir, "project.json");
var buildCmd = new BuildCommand(testProject, output: outputDir, framework: DefaultFramework); var buildCmd = new BuildCommand(testProject, output: outputDir, framework: DefaultFramework);
var result = buildCmd.ExecuteWithCapturedOutput(); var result = buildCmd.ExecuteWithCapturedOutput();
result.Should().Pass(); result.Should().Pass();
@ -75,15 +64,15 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
[Fact] [Fact]
public void LibraryWithAnalyzer() public void LibraryWithAnalyzer()
{ {
var root = Temp.CreateDirectory(); var testInstance = TestAssetsManager
var testLibDir = root.CreateDirectory("TestLibraryWithAnalyzer"); .CreateTestInstance("TestLibraryWithAnalyzer")
var sourceTestLibDir = Path.Combine(_testProjectsRoot, "TestLibraryWithAnalyzer"); .WithLockFiles();
CopyProjectToTempDir(sourceTestLibDir, testLibDir); var testLibDir = testInstance.TestRoot;
// run compile // run compile
var outputDir = Path.Combine(testLibDir.Path, "bin"); var outputDir = Path.Combine(testLibDir, "bin");
var testProject = GetProjectPath(testLibDir); var testProject = Path.Combine(testLibDir, "project.json");
var buildCmd = new BuildCommand(testProject, output: outputDir, framework: DefaultLibraryFramework); var buildCmd = new BuildCommand(testProject, output: outputDir, framework: DefaultLibraryFramework);
var result = buildCmd.ExecuteWithCapturedOutput(); var result = buildCmd.ExecuteWithCapturedOutput();
result.Should().Pass(); result.Should().Pass();
@ -96,12 +85,15 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
{ {
var root = Temp.CreateDirectory(); var root = Temp.CreateDirectory();
var spaceBufferDirectory = root.CreateDirectory("space directory"); var testInstance = TestAssetsManager
var testAppDir = spaceBufferDirectory.CreateDirectory("TestAppCompilationContext"); .CreateTestInstance("TestAppCompilationContext", identifier: "A SPACE")
.WithLockFiles();
CopyProjectToTempDir(Path.Combine(_testProjectsRoot, "TestAppCompilationContext"), testAppDir); var testProjectDir = Path.Combine(
Directory.GetParent(testInstance.TestRoot).FullName,
"TestAppCompilationContext",
"TestApp");
var testProjectDir = Path.Combine(_testProjectsRoot, "TestAppCompilationContext", "TestApp");
var testProject = Path.Combine(testProjectDir, "project.json"); var testProject = Path.Combine(testProjectDir, "project.json");
var buildCommand = new BuildCommand(testProject); var buildCommand = new BuildCommand(testProject);

View file

@ -13,7 +13,7 @@
"target": "project" "target": "project"
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21" "dotnet-test-xunit": "1.0.0-rc2-330423-54"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -30,7 +30,7 @@
"target": "project" "target": "project"
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21", "dotnet-test-xunit": "1.0.0-rc2-330423-54",
"moq.netcore": "4.4.0-beta8", "moq.netcore": "4.4.0-beta8",
"FluentAssertions": "4.2.2" "FluentAssertions": "4.2.2"
}, },

View file

@ -13,7 +13,7 @@
"target": "project" "target": "project"
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21" "dotnet-test-xunit": "1.0.0-rc2-330423-54"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -17,49 +17,41 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
{ {
private readonly string _testProjectsRoot; private readonly string _testProjectsRoot;
public PackTests()
{
_testProjectsRoot = Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects");
}
[Fact] [Fact]
public void OutputsPackagesToConfigurationSubdirWhenOutputParameterIsNotPassed() public void OutputsPackagesToConfigurationSubdirWhenOutputParameterIsNotPassed()
{ {
var root = Temp.CreateDirectory(); var testInstance = TestAssetsManager
.CreateTestInstance("TestLibraryWithConfiguration")
.WithBuildArtifacts()
.WithLockFiles();
var testLibDir = root.CreateDirectory("TestLibrary"); var testProject = Path.Combine(testInstance.Path, "project.json");
var sourceTestLibDir = Path.Combine(_testProjectsRoot, "TestLibraryWithConfiguration");
CopyProjectToTempDir(sourceTestLibDir, testLibDir);
var testProject = GetProjectPath(testLibDir);
var packCommand = new PackCommand(testProject, configuration: "Test"); var packCommand = new PackCommand(testProject, configuration: "Test");
var result = packCommand.Execute(); var result = packCommand.Execute();
result.Should().Pass(); result.Should().Pass();
var outputDir = new DirectoryInfo(Path.Combine(testLibDir.Path, "bin", "Test")); var outputDir = new DirectoryInfo(Path.Combine(testInstance.Path, "bin", "Test"));
outputDir.Should().Exist(); outputDir.Should().Exist();
outputDir.Should().HaveFiles(new [] { "TestLibrary.1.0.0.nupkg" , "TestLibrary.1.0.0.symbols.nupkg" }); outputDir.Should().HaveFiles(new [] { "TestLibraryWithConfiguration.1.0.0.nupkg" , "TestLibraryWithConfiguration.1.0.0.symbols.nupkg" });
} }
[Fact] [Fact]
public void OutputsPackagesFlatIntoOutputDirWhenOutputParameterIsPassed() public void OutputsPackagesFlatIntoOutputDirWhenOutputParameterIsPassed()
{ {
var root = Temp.CreateDirectory(); var testInstance = TestAssetsManager
.CreateTestInstance("TestLibraryWithConfiguration")
.WithBuildArtifacts()
.WithLockFiles();
var testLibDir = root.CreateDirectory("TestLibrary"); var testProject = Path.Combine(testInstance.Path, "project.json");
var sourceTestLibDir = Path.Combine(_testProjectsRoot, "TestLibraryWithConfiguration");
CopyProjectToTempDir(sourceTestLibDir, testLibDir); var outputDir = new DirectoryInfo(Path.Combine(testInstance.Path, "bin2"));
var outputDir = new DirectoryInfo(Path.Combine(testLibDir.Path, "bin2"));
var testProject = GetProjectPath(testLibDir);
var packCommand = new PackCommand(testProject, output: outputDir.FullName); var packCommand = new PackCommand(testProject, output: outputDir.FullName);
var result = packCommand.Execute(); var result = packCommand.Execute();
result.Should().Pass(); result.Should().Pass();
outputDir.Should().Exist(); outputDir.Should().Exist();
outputDir.Should().HaveFiles(new[] { "TestLibrary.1.0.0.nupkg", "TestLibrary.1.0.0.symbols.nupkg" }); outputDir.Should().HaveFiles(new[] { "TestLibraryWithConfiguration.1.0.0.nupkg", "TestLibraryWithConfiguration.1.0.0.symbols.nupkg" });
} }
[Fact] [Fact]
@ -100,9 +92,10 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
[Fact] [Fact]
public void HasIncludedFiles() public void HasIncludedFiles()
{ {
var testInstance = TestAssetsManager.CreateTestInstance("EndToEndTestApp") var testInstance = TestAssetsManager
.WithLockFiles() .CreateTestInstance("EndToEndTestApp")
.WithBuildArtifacts(); .WithLockFiles()
.WithBuildArtifacts();
var cmd = new PackCommand(Path.Combine(testInstance.TestRoot, Project.FileName)); var cmd = new PackCommand(Path.Combine(testInstance.TestRoot, Project.FileName));
cmd.Execute().Should().Pass(); cmd.Execute().Should().Pass();
@ -156,27 +149,25 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
[Fact] [Fact]
public void HasServiceableFlagWhenArgumentPassed() public void HasServiceableFlagWhenArgumentPassed()
{ {
var root = Temp.CreateDirectory(); var testInstance = TestAssetsManager
.CreateTestInstance("TestLibraryWithConfiguration")
.WithBuildArtifacts()
.WithLockFiles();
var testLibDir = root.CreateDirectory("TestLibrary"); var testProject = Path.Combine(testInstance.Path, "project.json");
var sourceTestLibDir = Path.Combine(_testProjectsRoot, "TestLibraryWithConfiguration");
CopyProjectToTempDir(sourceTestLibDir, testLibDir);
var testProject = GetProjectPath(testLibDir);
var packCommand = new PackCommand(testProject, configuration: "Debug", serviceable: true); var packCommand = new PackCommand(testProject, configuration: "Debug", serviceable: true);
var result = packCommand.Execute(); var result = packCommand.Execute();
result.Should().Pass(); result.Should().Pass();
var outputDir = new DirectoryInfo(Path.Combine(testLibDir.Path, "bin", "Debug")); var outputDir = new DirectoryInfo(Path.Combine(testInstance.Path, "bin", "Debug"));
outputDir.Should().Exist(); outputDir.Should().Exist();
outputDir.Should().HaveFiles(new[] { "TestLibrary.1.0.0.nupkg", "TestLibrary.1.0.0.symbols.nupkg" }); outputDir.Should().HaveFiles(new[] { "TestLibraryWithConfiguration.1.0.0.nupkg", "TestLibraryWithConfiguration.1.0.0.symbols.nupkg" });
var outputPackage = Path.Combine(outputDir.FullName, "TestLibrary.1.0.0.nupkg"); var outputPackage = Path.Combine(outputDir.FullName, "TestLibraryWithConfiguration.1.0.0.nupkg");
var zip = ZipFile.Open(outputPackage, ZipArchiveMode.Read); var zip = ZipFile.Open(outputPackage, ZipArchiveMode.Read);
zip.Entries.Should().Contain(e => e.FullName == "TestLibrary.nuspec"); zip.Entries.Should().Contain(e => e.FullName == "TestLibraryWithConfiguration.nuspec");
var manifestReader = new StreamReader(zip.Entries.First(e => e.FullName == "TestLibrary.nuspec").Open()); var manifestReader = new StreamReader(zip.Entries.First(e => e.FullName == "TestLibraryWithConfiguration.nuspec").Open());
var nuspecXml = XDocument.Parse(manifestReader.ReadToEnd()); var nuspecXml = XDocument.Parse(manifestReader.ReadToEnd());
var node = nuspecXml.Descendants().Single(e => e.Name.LocalName == "serviceable"); var node = nuspecXml.Descendants().Single(e => e.Name.LocalName == "serviceable");
Assert.Equal("true", node.Value); Assert.Equal("true", node.Value);

View file

@ -14,7 +14,7 @@
"target": "project" "target": "project"
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21" "dotnet-test-xunit": "1.0.0-rc2-330423-54"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -14,7 +14,7 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
[Fact] [Fact]
public void PublishExcludesBuildDependencies() public void PublishExcludesBuildDependencies()
{ {
var testInstance = TestAssetsManager.CreateTestInstance("AppWithDirectDependencyAndTypeBuild") var testInstance = TestAssetsManager.CreateTestInstance("AppWithDirectDepAndTypeBuild")
.WithLockFiles(); .WithLockFiles();
var publishCommand = new PublishCommand(testInstance.TestRoot); var publishCommand = new PublishCommand(testInstance.TestRoot);
@ -37,7 +37,7 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
// Check the deps file // Check the deps file
var reader = new DependencyContextJsonReader(); var reader = new DependencyContextJsonReader();
DependencyContext context; DependencyContext context;
using (var file = File.OpenRead(Path.Combine(publishDir.FullName, "AppWithDirectDependencyAndTypeBuild.deps.json"))) using (var file = File.OpenRead(Path.Combine(publishDir.FullName, "AppWithDirectDepAndTypeBuild.deps.json")))
{ {
context = reader.Read(file); context = reader.Read(file);
} }

View file

@ -14,14 +14,8 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
{ {
public class PublishTests : TestBase public class PublishTests : TestBase
{ {
private readonly string _testProjectsRoot;
private readonly Func<string, string, string> _getProjectJson = ProjectUtils.GetProjectJson; private readonly Func<string, string, string> _getProjectJson = ProjectUtils.GetProjectJson;
public PublishTests()
{
_testProjectsRoot = Path.Combine(RepoRoot, "TestAssets", "TestProjects");
}
private static readonly dynamic[] CrossPublishTestData = new[] private static readonly dynamic[] CrossPublishTestData = new[]
{ {
new new

View file

@ -14,7 +14,7 @@
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"xunit.netcore.extensions": "1.0.0-prerelease-00206", "xunit.netcore.extensions": "1.0.0-prerelease-00206",
"dotnet-test-xunit": "1.0.0-rc2-318883-21", "dotnet-test-xunit": "1.0.0-rc2-330423-54",
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0" "System.Runtime.InteropServices.RuntimeInformation": "4.0.0"
}, },
"frameworks": { "frameworks": {

View file

@ -12,24 +12,16 @@ namespace Microsoft.DotNet.Tools.Resgen.Tests
{ {
public class ResgenTests : TestBase public class ResgenTests : TestBase
{ {
private readonly string _testProjectsRoot;
private readonly TempDirectory _root;
public ResgenTests()
{
_testProjectsRoot = Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects");
_root = Temp.CreateDirectory();
}
[Fact] [Fact]
public void Test_Build_Project_with_Resources_with_Space_in_Path_Should_Succeed() public void Test_Build_Project_with_Resources_with_Space_in_Path_Should_Succeed()
{ {
var spaceBufferDirectory = _root.CreateDirectory("space directory"); var testInstance = TestAssetsManager
var testAppDir = spaceBufferDirectory.CreateDirectory("TestProjectWithResource"); .CreateTestInstance("TestProjectWithResource", identifier: "A SPACE")
.WithBuildArtifacts()
.WithLockFiles();
CopyProjectToTempDir(Path.Combine(_testProjectsRoot, "TestProjectWithResource"), testAppDir); var testProject = Path.Combine(testInstance.Path, "project.json");
var testProject = GetProjectPath(testAppDir);
var buildCommand = new BuildCommand(testProject); var buildCommand = new BuildCommand(testProject);
buildCommand.Execute().Should().Pass(); buildCommand.Execute().Should().Pass();

View file

@ -14,7 +14,7 @@
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"xunit.netcore.extensions": "1.0.0-prerelease-00206", "xunit.netcore.extensions": "1.0.0-prerelease-00206",
"dotnet-test-xunit": "1.0.0-rc2-318883-21" "dotnet-test-xunit": "1.0.0-rc2-330423-54"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -13,7 +13,7 @@
"target": "project" "target": "project"
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21" "dotnet-test-xunit": "1.0.0-rc2-330423-54"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -14,7 +14,7 @@
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"moq.netcore": "4.4.0-beta8", "moq.netcore": "4.4.0-beta8",
"dotnet-test-xunit": "1.0.0-rc2-318883-21" "dotnet-test-xunit": "1.0.0-rc2-330423-54"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -19,8 +19,8 @@
"System.Net.Sockets": "4.1.0", "System.Net.Sockets": "4.1.0",
"System.Runtime.Serialization.Primitives": "4.1.1", "System.Runtime.Serialization.Primitives": "4.1.1",
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21", "dotnet-test-xunit": "1.0.0-rc2-330423-54",
"Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000914" "Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000919"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {

View file

@ -14,7 +14,7 @@
"exclude": "Compile" "exclude": "Compile"
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21", "dotnet-test-xunit": "1.0.0-rc2-330423-54",
"moq.netcore": "4.4.0-beta8", "moq.netcore": "4.4.0-beta8",
"FluentAssertions": "4.2.2" "FluentAssertions": "4.2.2"
}, },

View file

@ -31,14 +31,15 @@ namespace Microsoft.DotNet.Tests
_firstDotnetNonVerbUseCommandResult = command.ExecuteWithCapturedOutput("--info"); _firstDotnetNonVerbUseCommandResult = command.ExecuteWithCapturedOutput("--info");
_firstDotnetVerbUseCommandResult = command.ExecuteWithCapturedOutput("new"); _firstDotnetVerbUseCommandResult = command.ExecuteWithCapturedOutput("new");
_nugetCacheFolder = new DirectoryInfo(testNugetCache); _nugetCacheFolder = new DirectoryInfo(testNugetCache);
} }
[Fact] [Fact]
public void Using_dotnet_for_the_first_time_succeeds() public void Using_dotnet_for_the_first_time_succeeds()
{ {
_firstDotnetVerbUseCommandResult.Should().Pass(); _firstDotnetVerbUseCommandResult
.Should()
.Pass();
} }
[Fact] [Fact]
@ -46,7 +47,9 @@ namespace Microsoft.DotNet.Tests
{ {
const string firstTimeNonVerbUseMessage = @".NET Command Line Tools"; const string firstTimeNonVerbUseMessage = @".NET Command Line Tools";
_firstDotnetNonVerbUseCommandResult.StdOut.Should().StartWith(firstTimeNonVerbUseMessage); _firstDotnetNonVerbUseCommandResult.StdOut
.Should()
.StartWith(firstTimeNonVerbUseMessage);
} }
[Fact] [Fact]
@ -64,19 +67,25 @@ Configuring...
------------------- -------------------
A command is running to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once."; A command is running to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once.";
_firstDotnetVerbUseCommandResult.StdOut.Should().StartWith(firstTimeUseWelcomeMessage); _firstDotnetVerbUseCommandResult.StdOut
.Should()
.StartWith(firstTimeUseWelcomeMessage);
} }
[Fact] [Fact]
public void It_restores_the_nuget_packages_to_the_nuget_cache_folder() public void It_restores_the_nuget_packages_to_the_nuget_cache_folder()
{ {
_nugetCacheFolder.Should().HaveFile($"{GetDotnetVersion()}.dotnetSentinel"); _nugetCacheFolder
.Should()
.HaveFile($"{GetDotnetVersion()}.dotnetSentinel");
} }
[Fact] [Fact]
public void It_creates_a_sentinel_file_under_the_nuget_cache_folder() public void It_creates_a_sentinel_file_under_the_nuget_cache_folder()
{ {
_nugetCacheFolder.Should().HaveDirectory("microsoft.netcore.app"); _nugetCacheFolder
.Should()
.HaveDirectory("microsoft.netcore.app");
} }
private string GetDotnetVersion() private string GetDotnetVersion()

View file

@ -7,6 +7,7 @@ using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using FluentAssertions; using FluentAssertions;
using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.TestFramework;
using Microsoft.DotNet.Tools.Test.Utilities; using Microsoft.DotNet.Tools.Test.Utilities;
using Microsoft.DotNet.InternalAbstractions; using Microsoft.DotNet.InternalAbstractions;
using Xunit; using Xunit;
@ -15,19 +16,18 @@ namespace Microsoft.DotNet.Tests
{ {
public class PackagedCommandTests : TestBase public class PackagedCommandTests : TestBase
{ {
private readonly string _testProjectsRoot; private readonly TestAssetsManager _desktopTestAssetsManager = GetTestGroupTestAssetsManager("DesktopTestProjects");
private readonly string _desktopTestProjectsRoot;
public static IEnumerable<object[]> DependencyToolArguments public static IEnumerable<object[]> DependencyToolArguments
{ {
get get
{ {
var rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier(); var rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier();
var projectOutputPath = $"AppWithDirectDependencyDesktopAndPortable\\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[]
{ {
new object[] { ".NETCoreApp,Version=v1.0", "CoreFX", "lib\\netcoreapp1.0\\dotnet-desktop-and-portable.dll", true }, new object[] { "CoreFX", ".NETCoreApp,Version=v1.0", "lib\\netcoreapp1.0\\dotnet-desktop-and-portable.dll", true },
new object[] { ".NETFramework,Version=v4.5.1", "NetFX", projectOutputPath, true } new object[] { "NetFX", ".NETFramework,Version=v4.5.1", projectOutputPath, true }
}; };
} }
} }
@ -40,24 +40,22 @@ namespace Microsoft.DotNet.Tests
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[]
{ {
new object[] { ".NETStandard,Version=v1.6", "CoreFX", "lib\\netstandard1.6\\dotnet-desktop-and-portable.dll", true }, new object[] { "CoreFX", ".NETStandard,Version=v1.6", "lib\\netstandard1.6\\dotnet-desktop-and-portable.dll", true },
new object[] { ".NETFramework,Version=v4.5.1", "NetFX", projectOutputPath, true } new object[] { "NetFX", ".NETFramework,Version=v4.5.1", projectOutputPath, true }
}; };
} }
} }
public PackagedCommandTests()
{
_testProjectsRoot = Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects");
_desktopTestProjectsRoot = Path.Combine(AppContext.BaseDirectory, "TestAssets", "DesktopTestProjects");
}
[Theory] [Theory]
[InlineData("AppWithDirectAndToolDependency")] [InlineData("AppWithDirectAndToolDep")]
[InlineData("AppWithToolDependency")] [InlineData("AppWithToolDependency")]
public void TestProjectToolIsAvailableThroughDriver(string appName) public void TestProjectToolIsAvailableThroughDriver(string appName)
{ {
var appDirectory = Path.Combine(_testProjectsRoot, appName); var testInstance = TestAssetsManager
.CreateTestInstance(appName, identifier: appName)
.WithLockFiles();
var appDirectory = testInstance.Path;
new BuildCommand(Path.Combine(appDirectory, "project.json")) new BuildCommand(Path.Combine(appDirectory, "project.json"))
.Execute() .Execute()
@ -75,7 +73,11 @@ namespace Microsoft.DotNet.Tests
[Fact] [Fact]
public void CanInvokeToolWhosePackageNameIsDifferentFromDllName() public void CanInvokeToolWhosePackageNameIsDifferentFromDllName()
{ {
var appDirectory = Path.Combine(_testProjectsRoot, "AppWithDependencyOnToolWithOutputName"); var testInstance = TestAssetsManager
.CreateTestInstance("AppWithDepOnToolWithOutputName")
.WithLockFiles();
var appDirectory = testInstance.Path;
new BuildCommand(Path.Combine(appDirectory, "project.json")) new BuildCommand(Path.Combine(appDirectory, "project.json"))
.Execute() .Execute()
@ -93,7 +95,12 @@ namespace Microsoft.DotNet.Tests
[Fact] [Fact]
public void CanInvokeToolFromDirectDependenciesIfPackageNameDifferentFromToolName() public void CanInvokeToolFromDirectDependenciesIfPackageNameDifferentFromToolName()
{ {
var appDirectory = Path.Combine(_testProjectsRoot, "AppWithDirectDependencyWithOutputName"); var testInstance = TestAssetsManager
.CreateTestInstance("AppWithDirectDepWithOutputName")
.WithBuildArtifacts()
.WithLockFiles();
var appDirectory = testInstance.Path;
const string framework = ".NETCoreApp,Version=v1.0"; const string framework = ".NETCoreApp,Version=v1.0";
new BuildCommand(Path.Combine(appDirectory, "project.json")) new BuildCommand(Path.Combine(appDirectory, "project.json"))
@ -112,14 +119,19 @@ namespace Microsoft.DotNet.Tests
// need conditional theories so we can skip on non-Windows // need conditional theories so we can skip on non-Windows
[Theory] [Theory]
[MemberData("DependencyToolArguments")] [MemberData("DependencyToolArguments")]
public void TestFrameworkSpecificDependencyToolsCanBeInvoked(string framework, string args, string expectedDependencyToolPath, bool windowsOnly) public void TestFrameworkSpecificDependencyToolsCanBeInvoked(string identifier, string framework, string expectedDependencyToolPath, bool windowsOnly)
{ {
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && windowsOnly) if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && windowsOnly)
{ {
return; return;
} }
var appDirectory = Path.Combine(_desktopTestProjectsRoot, "AppWithDirectDependencyDesktopAndPortable"); var testInstance = _desktopTestAssetsManager
.CreateTestInstance("AppWithDirectDepDesktopAndPortable", identifier: identifier)
.WithBuildArtifacts()
.WithLockFiles();
var appDirectory = testInstance.Path;
new BuildCommand(Path.Combine(appDirectory, "project.json")) new BuildCommand(Path.Combine(appDirectory, "project.json"))
.Execute() .Execute()
@ -127,10 +139,10 @@ namespace Microsoft.DotNet.Tests
.Pass(); .Pass();
CommandResult result = new DependencyToolInvokerCommand { WorkingDirectory = appDirectory } CommandResult result = new DependencyToolInvokerCommand { WorkingDirectory = appDirectory }
.ExecuteWithCapturedOutput("desktop-and-portable", framework, args); .ExecuteWithCapturedOutput("desktop-and-portable", framework, identifier);
result.Should().HaveStdOutContaining(framework); result.Should().HaveStdOutContaining(framework);
result.Should().HaveStdOutContaining(args); result.Should().HaveStdOutContaining(identifier);
result.Should().HaveStdOutContaining(expectedDependencyToolPath); result.Should().HaveStdOutContaining(expectedDependencyToolPath);
result.Should().NotHaveStdErr(); result.Should().NotHaveStdErr();
result.Should().Pass(); result.Should().Pass();
@ -138,14 +150,18 @@ namespace Microsoft.DotNet.Tests
[Theory] [Theory]
[MemberData("LibraryDependencyToolArguments")] [MemberData("LibraryDependencyToolArguments")]
public void TestFrameworkSpecificLibraryDependencyToolsCannotBeInvoked(string framework, string args, string expectedDependencyToolPath, bool windowsOnly) public void TestFrameworkSpecificLibraryDependencyToolsCannotBeInvoked(string identifier, string framework, string expectedDependencyToolPath, bool windowsOnly)
{ {
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && windowsOnly) if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && windowsOnly)
{ {
return; return;
} }
var testInstance = _desktopTestAssetsManager
.CreateTestInstance("LibraryWithDirectDependencyDesktopAndPortable", identifier: identifier)
.WithLockFiles();
var appDirectory = Path.Combine(_desktopTestProjectsRoot, "LibraryWithDirectDependencyDesktopAndPortable"); var appDirectory = testInstance.Path;
new BuildCommand(Path.Combine(appDirectory, "project.json")) new BuildCommand(Path.Combine(appDirectory, "project.json"))
.Execute() .Execute()
@ -153,7 +169,7 @@ namespace Microsoft.DotNet.Tests
.Pass(); .Pass();
CommandResult result = new DependencyToolInvokerCommand { WorkingDirectory = appDirectory } CommandResult result = new DependencyToolInvokerCommand { WorkingDirectory = appDirectory }
.ExecuteWithCapturedOutput("desktop-and-portable", framework, args); .ExecuteWithCapturedOutput("desktop-and-portable", framework, identifier);
result.Should().HaveStdOutContaining("Command not found"); result.Should().HaveStdOutContaining("Command not found");
result.Should().Fail(); result.Should().Fail();
@ -162,7 +178,9 @@ namespace Microsoft.DotNet.Tests
[Fact] [Fact]
public void ToolsCanAccessDependencyContextProperly() public void ToolsCanAccessDependencyContextProperly()
{ {
var appDirectory = Path.Combine(_testProjectsRoot, "DependencyContextFromTool"); var testInstance = TestAssetsManager.CreateTestInstance("DependencyContextFromTool");
var appDirectory = testInstance.Path;
CommandResult result = new DependencyContextTestCommand() { WorkingDirectory = appDirectory } CommandResult result = new DependencyContextTestCommand() { WorkingDirectory = appDirectory }
.Execute(Path.Combine(appDirectory, "project.json")); .Execute(Path.Combine(appDirectory, "project.json"));
@ -173,8 +191,11 @@ namespace Microsoft.DotNet.Tests
[Fact] [Fact]
public void TestProjectDependencyIsNotAvailableThroughDriver() public void TestProjectDependencyIsNotAvailableThroughDriver()
{ {
var appName = "AppWithDirectDependency"; var testInstance = TestAssetsManager
var appDirectory = Path.Combine(_testProjectsRoot, appName); .CreateTestInstance("AppWithDirectDep")
.WithLockFiles();
var appDirectory = testInstance.Path;
new BuildCommand(Path.Combine(appDirectory, "project.json")) new BuildCommand(Path.Combine(appDirectory, "project.json"))
.Execute() .Execute()

View file

@ -17,8 +17,8 @@
"type": "build" "type": "build"
}, },
"xunit": "2.2.0-beta3-build3330", "xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21", "dotnet-test-xunit": "1.0.0-rc2-330423-54",
"Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000914" "Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000919"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {