dotnet-build3 Adding msbuild execution command to cli

This commit is contained in:
Bryan Thornbury 2016-06-17 16:16:09 -07:00
parent 349c409ed2
commit 400e1db3b9
17 changed files with 493 additions and 24 deletions

View file

@ -121,6 +121,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.Configurer
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.Archive", "src\Microsoft.DotNet.Archive\Microsoft.DotNet.Archive.xproj", "{35B19F22-B8C0-4849-9C35-3F809B7588B8}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "dotnet-build3.Tests", "test\dotnet-build3.Tests\dotnet-build3.Tests.xproj", "{49D7318E-D198-4E2B-BBEA-3A24D805F88D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -805,22 +807,6 @@ Global
{A28BD8AC-DF15-4F58-8299-98A9AE2B8726}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{A28BD8AC-DF15-4F58-8299-98A9AE2B8726}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{A28BD8AC-DF15-4F58-8299-98A9AE2B8726}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.Debug|x64.ActiveCfg = Debug|Any CPU
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.Debug|x64.Build.0 = Debug|Any CPU
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.MinSizeRel|x64.Build.0 = Debug|Any CPU
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.Release|Any CPU.Build.0 = Release|Any CPU
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.Release|x64.ActiveCfg = Release|Any CPU
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.Release|x64.Build.0 = Release|Any CPU
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{1C599FFD-FB52-4279-A8E5-465D3EC499E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1C599FFD-FB52-4279-A8E5-465D3EC499E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1C599FFD-FB52-4279-A8E5-465D3EC499E1}.Debug|x64.ActiveCfg = Debug|Any CPU
@ -901,6 +887,22 @@ Global
{35B19F22-B8C0-4849-9C35-3F809B7588B8}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{35B19F22-B8C0-4849-9C35-3F809B7588B8}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{35B19F22-B8C0-4849-9C35-3F809B7588B8}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{49D7318E-D198-4E2B-BBEA-3A24D805F88D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{49D7318E-D198-4E2B-BBEA-3A24D805F88D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{49D7318E-D198-4E2B-BBEA-3A24D805F88D}.Debug|x64.ActiveCfg = Debug|Any CPU
{49D7318E-D198-4E2B-BBEA-3A24D805F88D}.Debug|x64.Build.0 = Debug|Any CPU
{49D7318E-D198-4E2B-BBEA-3A24D805F88D}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
{49D7318E-D198-4E2B-BBEA-3A24D805F88D}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
{49D7318E-D198-4E2B-BBEA-3A24D805F88D}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
{49D7318E-D198-4E2B-BBEA-3A24D805F88D}.MinSizeRel|x64.Build.0 = Debug|Any CPU
{49D7318E-D198-4E2B-BBEA-3A24D805F88D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{49D7318E-D198-4E2B-BBEA-3A24D805F88D}.Release|Any CPU.Build.0 = Release|Any CPU
{49D7318E-D198-4E2B-BBEA-3A24D805F88D}.Release|x64.ActiveCfg = Release|Any CPU
{49D7318E-D198-4E2B-BBEA-3A24D805F88D}.Release|x64.Build.0 = Release|Any CPU
{49D7318E-D198-4E2B-BBEA-3A24D805F88D}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
{49D7318E-D198-4E2B-BBEA-3A24D805F88D}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{49D7318E-D198-4E2B-BBEA-3A24D805F88D}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{49D7318E-D198-4E2B-BBEA-3A24D805F88D}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -953,11 +955,11 @@ Global
{49BEB486-AB5A-4416-91EA-8CD34ABB0C9D} = {88278B81-7649-45DC-8A6A-D3A645C5AFC3}
{B768BD29-12BF-4C7C-B093-03193FE244D1} = {88278B81-7649-45DC-8A6A-D3A645C5AFC3}
{A28BD8AC-DF15-4F58-8299-98A9AE2B8726} = {88278B81-7649-45DC-8A6A-D3A645C5AFC3}
{1DBB7542-0345-4F4B-A84B-3B00B185D416} = {88278B81-7649-45DC-8A6A-D3A645C5AFC3}
{1C599FFD-FB52-4279-A8E5-465D3EC499E1} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{5DF6C9DA-6909-4EC0-909E-6913580BB4A4} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
{E5ED47EF-BF25-4DA9-A7FE-290C642CBF0F} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{4C3B06D5-B6D5-4E5B-A44F-3EBE52A1C759} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
{35B19F22-B8C0-4849-9C35-3F809B7588B8} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{49D7318E-D198-4E2B-BBEA-3A24D805F88D} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft.NuGet.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<PlatformTarget Condition=" '$(PlatformTarget)' == '' ">x64</PlatformTarget>
<OutputType>Exe</OutputType>
<RootNamespace>MSBuildTestApp</RootNamespace>
<AssemblyName>$(MSBuildThisFileName)</AssemblyName>
<TargetFrameworkIdentifier>NETCoreApp</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
<OutputPath>bin\$(Configuration)\netcoreapp1.0</OutputPath>
<AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<NoStdLib>true</NoStdLib>
<NoLogo>true</NoLogo> <!-- Temp Hack: https://github.com/dotnet/roslyn/issues/12167 -->
<NuGetTargetMoniker>.NETCoreApp,Version=v1.0</NuGetTargetMoniker>
<!-- Temp Hack: Being passed through from cli, where should this come from? -->
<BaseNuGetRuntimeIdentifier Condition=" '$(BaseNuGetRuntimeIdentifier)' == '' ">win7</BaseNuGetRuntimeIdentifier>
<DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType>
</PropertyGroup>
<ItemGroup>
<Compile Include="**\*.cs" />
</ItemGroup>
<PropertyGroup>
<!-- Temp Hack: https://github.com/Microsoft/msbuild/issues/720 -->
<OverrideToolHost Condition=" '$(DotnetHostPath)' != '' and '$(OverrideToolHost)' == ''">$(DotnetHostPath)</OverrideToolHost>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft.NuGet.targets" />
<!-- Temporary Hack, this should happen in build -->
<Target Name="AfterBuild">
<Move SourceFiles="$(TargetPath)" DestinationFiles="$(TargetDir)\$(AssemblyName).dll" />
<Copy SourceFiles="$(DotnetHostPath)" DestinationFiles="$(TargetPath)" />
</Target>
</Project>

View file

@ -0,0 +1,12 @@
using System;
namespace MSBuildTestApp
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}

View file

@ -0,0 +1,28 @@
{
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0"
}
}
}
},
"runtimes": {
"win7-x64": {},
"win7-x86": {},
"win81-x64": {},
"win81-x86": {},
"win10-x64": {},
"win10-x86": {},
"osx.10.10-x64": {},
"osx.10.11-x64": {},
"ubuntu.14.04-x64": {},
"ubuntu.16.04-x64": {},
"centos.7-x64": {},
"rhel.7.2-x64": {},
"debian.8-x64": {},
"fedora.23-x64": {},
"opensuse.13.2-x64": {}
},
}

49
build.proj Normal file
View file

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="BuildTheWholeCli" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!--
$(OS) is set to Unix/Windows_NT. This comes from an environment variable on Windows and MSBuild on Unix.
-->
<PlatformScriptHost Condition=" '$(OS)' == 'Windows_NT' ">powershell -NoProfile -NoLogo -Command </PlatformScriptHost>
<PlatformScriptHost Condition=" '$(OS)' != 'Windows_NT' "></PlatformScriptHost>
<PlatformScriptExtension Condition=" '$(OS)' == 'Windows_NT' ">.ps1</PlatformScriptExtension>
<PlatformScriptExtension Condition=" '$(OS)' != 'Windows_NT' ">.sh</PlatformScriptExtension>
<PlatformExeExtension Condition=" '$(OS)' == 'Windows_NT' ">.exe</PlatformExeExtension>
<PlatformExeExtension Condition=" '$(OS)' != 'Windows_NT' "></PlatformExeExtension>
<CLITargets Condition=" '$(CLITargets)' == '' ">Prepare;Compile;Test;Package;Publish</CLITargets>
</PropertyGroup>
<Target Name="BuildDotnetCliBuildFramework" Inputs="" Outputs="">
<Exec Command="$(PlatformScriptHost) $(MSBuildThisFileDirectory)/build_projects/dotnet-cli-build/build$(PlatformScriptExtension)" WorkingDirectory="$(MSBuildThisFileDirectory)"/>
<PropertyGroup>
<CliBuildFrameworkExe>$(MSBuildThisFileDirectory)/build_projects/dotnet-cli-build/bin/dotnet-cli-build$(PlatformExeExtension)</CliBuildFrameworkExe>
</PropertyGroup>
</Target>
<Target DependsOnTargets="BuildDotnetCliBuildFramework;$(CLITargets)" Name="BuildTheWholeCli"></Target>
<Target DependsOnTargets="BuildDotnetCliBuildFramework" Name="Prepare">
<Exec Command="$(CliBuildFrameworkExe) Prepare" WorkingDirectory="$(MSBuildThisFileDirectory)"/>
</Target>
<Target DependsOnTargets="BuildDotnetCliBuildFramework" Name="Compile">
<Exec Command="$(CliBuildFrameworkExe) Compile" WorkingDirectory="$(MSBuildThisFileDirectory)" />
</Target>
<Target DependsOnTargets="BuildDotnetCliBuildFramework" Name="Test">
<Exec Command="$(CliBuildFrameworkExe) Test" WorkingDirectory="$(MSBuildThisFileDirectory)" />
</Target>
<Target DependsOnTargets="BuildDotnetCliBuildFramework" Name="Package">
<Exec Command="$(CliBuildFrameworkExe) Package" WorkingDirectory="$(MSBuildThisFileDirectory)" />
</Target>
<Target DependsOnTargets="BuildDotnetCliBuildFramework" Name="Publish">
<Exec Command="$(CliBuildFrameworkExe) Publish" WorkingDirectory="$(MSBuildThisFileDirectory)" />
</Target>
</Project>

View file

@ -201,7 +201,6 @@ namespace Microsoft.DotNet.Cli.Build
var compilersDeps = Path.Combine(sdkOutputDirectory, "compilers.deps.json");
var compilersRuntimeConfig = Path.Combine(sdkOutputDirectory, "compilers.runtimeconfig.json");
var binaryToCorehostifyRelDir = Path.Combine("runtimes", "any", "native");
var binaryToCorehostifyOutDir = Path.Combine(sdkOutputDirectory, binaryToCorehostifyRelDir);
// Corehostify binaries
@ -211,7 +210,7 @@ namespace Microsoft.DotNet.Cli.Build
{
// Yes, it is .exe even on Linux. This is the managed exe we're working with
File.Copy(Path.Combine(binaryToCorehostifyOutDir, $"{binaryToCorehostify}.exe"), Path.Combine(sdkOutputDirectory, $"{binaryToCorehostify}.dll"));
File.Delete(Path.Combine(binaryToCorehostifyOutDir, $"{binaryToCorehostify}.exe"));
File.Move(Path.Combine(binaryToCorehostifyOutDir, $"{binaryToCorehostify}.exe"), Path.Combine(sdkOutputDirectory, $"{binaryToCorehostify}.exe"));
var binaryToCoreHostifyDeps = Path.Combine(sdkOutputDirectory, binaryToCorehostify + ".deps.json");
File.Copy(compilersDeps, Path.Combine(sdkOutputDirectory, binaryToCorehostify + ".deps.json"));
@ -221,6 +220,8 @@ namespace Microsoft.DotNet.Cli.Build
{
var assetPath = Path.Combine(binaryToCorehostifyRelDir, $"{binaryToRemove}.exe").Replace(Path.DirectorySeparatorChar, '/');
RemoveAssetFromDepsPackages(binaryToCoreHostifyDeps, "runtimeTargets", assetPath);
RemoveAssetFromDepsPackages(
Path.Combine(sdkOutputDirectory, "dotnet.deps.json"), "runtimeTargets", assetPath);
}
}
catch (Exception ex)
@ -270,9 +271,31 @@ namespace Microsoft.DotNet.Cli.Build
GenerateNuGetPackagesArchive(c, dotnet, sdkOutputDirectory);
}
CopyMSBuildTargetsToSDKRoot(sdkOutputDirectory);
return c.Success();
}
private static void CopyMSBuildTargetsToSDKRoot(string sdkOutputDirectory)
{
var msbuildTargetsDirectory = Path.Combine(sdkOutputDirectory, "runtimes", "any", "native");
var filesToCopy = new List<string>();
filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.targets", SearchOption.AllDirectories));
filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.Targets", SearchOption.AllDirectories));
filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.props", SearchOption.AllDirectories));
filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.overridetasks", SearchOption.AllDirectories));
filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.tasks", SearchOption.AllDirectories));
foreach (var fileFullPath in filesToCopy)
{
var fileRelativePath = fileFullPath.Substring(msbuildTargetsDirectory.Length + 1);
var destinationFilePath = Path.Combine(sdkOutputDirectory, fileRelativePath);
File.Copy(fileFullPath, destinationFilePath, true);
}
}
private static void GenerateNuGetPackagesArchive(
BuildTargetContext c,
DotNetCli dotnet,

View file

@ -22,6 +22,7 @@ namespace Microsoft.DotNet.Cli.Build
"EndToEnd",
"dotnet.Tests",
"dotnet-build.Tests",
"dotnet-build3.Tests",
"dotnet-compile.Tests",
"dotnet-compile.UnitTests",
// TODO: https://github.com/dotnet/cli/issues/3558

View file

@ -37,7 +37,8 @@ namespace Microsoft.DotNet.Cli
["publish"] = PublishCommand.Run,
["restore"] = RestoreCommand.Run,
["run"] = RunCommand.Run,
["test"] = TestCommand.Run
["test"] = TestCommand.Run,
["build3"] = Build3Command.Run
};
public static int Main(string[] args)

View file

@ -0,0 +1,107 @@
// 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 Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.ProjectModel;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
namespace Microsoft.DotNet.Cli
{
/// <summary>
/// A class which encapsulates logic needed to forward arguments from the current process to another process
/// invoked with the dotnet.exe host.
/// </summary>
public class ForwardingApp
{
private const string s_hostExe = "dotnet";
private readonly string _forwardApplicationPath;
private readonly string[] _argsToForward;
private readonly string _depsFile;
private readonly string _runtimeConfig;
private readonly string _additionalProbingPath;
private readonly Dictionary<string, string> _environmentVariables;
private readonly string[] _allArgs;
public ForwardingApp(
string forwardApplicationPath,
string[] argsToForward,
string depsFile = null,
string runtimeConfig = null,
string additionalProbingPath = null,
Dictionary<string, string> environmentVariables = null)
{
_forwardApplicationPath = forwardApplicationPath;
_argsToForward = argsToForward;
_depsFile = depsFile;
_runtimeConfig = runtimeConfig;
_additionalProbingPath = additionalProbingPath;
_environmentVariables = environmentVariables;
var allArgs = new List<string>();
allArgs.Add("exec");
if (_depsFile != null)
{
allArgs.Add("--depsfile");
allArgs.Add(_depsFile);
}
if (_runtimeConfig != null)
{
allArgs.Add("--runtimeconfig");
allArgs.Add(_runtimeConfig);
}
if (_additionalProbingPath != null)
{
allArgs.Add("--additionalprobingpath");
allArgs.Add(_additionalProbingPath);
}
allArgs.Add(_forwardApplicationPath);
allArgs.AddRange(_argsToForward);
_allArgs = allArgs.ToArray();
}
public int Execute()
{
var processInfo = new ProcessStartInfo
{
FileName = GetHostExeName(),
Arguments = ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(_allArgs),
UseShellExecute = false
};
if (_environmentVariables != null)
{
foreach (var entry in _environmentVariables)
{
processInfo.Environment[entry.Key] = entry.Value;
}
}
var process = new Process
{
StartInfo = processInfo
};
process.Start();
process.WaitForExit();
return process.ExitCode;
}
private string GetHostExeName()
{
return $"{s_hostExe}{FileNameSuffixes.CurrentPlatform.Exe}";
}
}
}

View file

@ -0,0 +1,80 @@
// 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 Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.InternalAbstractions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.DotNet.Cli
{
public class MSBuildForwardingApp
{
private const string s_msbuildExeName = "MSBuild.exe";
private readonly ForwardingApp _forwardingApp;
public MSBuildForwardingApp(string[] argsToForward)
{
_forwardingApp = new ForwardingApp(
GetMSBuildExePath(),
argsToForward,
depsFile: GetDepsFile(),
runtimeConfig: GetRuntimeConfig(),
environmentVariables: GetEnvironmentVariables());
}
public int Execute()
{
return _forwardingApp.Execute();
}
private static Dictionary<string, string> GetEnvironmentVariables()
{
return new Dictionary<string, string>
{
{ "MSBuildExtensionsPath", AppContext.BaseDirectory },
{ "DotnetHostPath", GetHostPath() },
{ "BaseNuGetRuntimeIdentifier", GetCurrentBaseRid() },
{ "Platform", GetCurrentArchitecture() },
{ "PlatformTarget", GetCurrentArchitecture() }
};
}
private static string GetCurrentBaseRid()
{
return RuntimeEnvironment.GetRuntimeIdentifier()
.Replace("-" + RuntimeEnvironment.RuntimeArchitecture, "");
}
private static string GetHostPath()
{
return new Muxer().MuxerPath;
}
private static string GetRuntimeConfig()
{
return Path.Combine(AppContext.BaseDirectory, "dotnet.runtimeconfig.json");
}
private static string GetDepsFile()
{
return Path.Combine(AppContext.BaseDirectory, "dotnet.deps.json");
}
private static string GetMSBuildExePath()
{
return Path.Combine(
AppContext.BaseDirectory,
"runtimes", "any", "native",
s_msbuildExeName);
}
private static string GetCurrentArchitecture()
{
return RuntimeEnvironment.RuntimeArchitecture;
}
}
}

View file

@ -0,0 +1,20 @@
// 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 Microsoft.DotNet.Cli.Utils;
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
namespace Microsoft.DotNet.Cli
{
public class Build3Command
{
public static int Run(string[] args)
{
return new MSBuildForwardingApp(args).Execute();
}
}
}

View file

@ -1,4 +1,7 @@
using Microsoft.DotNet.Cli.CommandLine;
// 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 Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Utils;
using System;
using System.Collections.Generic;

View file

@ -19,6 +19,7 @@ using NuGet.Frameworks;
using NuGet.Packaging.Core;
using NuGet.Versioning;
using PackageBuilder = NuGet.PackageBuilder;
using NuGetConstants = NuGet.Constants;
namespace Microsoft.DotNet.Tools.Compiler
{
@ -58,7 +59,7 @@ namespace Microsoft.DotNet.Tools.Compiler
var packageOutputPath = Path.Combine(
ArtifactPathsCalculator.PackageOutputPath,
GetPackageName() + NuGet.Constants.PackageExtension);
GetPackageName() + NuGetConstants.PackageExtension);
if (GeneratePackage(packageOutputPath, packDiagnostics))
{

View file

@ -52,14 +52,25 @@
},
"System.Diagnostics.TraceSource": "4.0.0",
"System.Diagnostics.TextWriterTraceListener": "4.0.0",
"System.Resources.Writer": "4.0.0",
"System.Runtime.Serialization.Primitives": "4.1.1",
"System.Private.DataContractSerialization": "4.1.1",
"System.Text.RegularExpressions": "4.1.0",
"Microsoft.Win32.Registry": {
"version": "4.0.0",
"exclude": "compile"
}
},
"MSBuild": "0.1.0-preview-00024-160610",
"Microsoft.Build.Framework": "0.1.0-preview-00024-160610",
"Microsoft.Build.Tasks.Core": "0.1.0-preview-00024-160610",
"Microsoft.Build.Utilities.Core": "0.1.0-preview-00024-160610",
"Microsoft.Build.Targets": "0.1.0-preview-00024-160610",
"Microsoft.Build": "0.1.0-preview-00024-160610",
"Microsoft.Net.Compilers.NetCore": "1.3.0",
"Microsoft.Net.Compilers.Targets.NetCore": "0.1.5-dev",
"Microsoft.Cci": "4.0.0-rc3-24128-00",
"Microsoft.Composition": "1.0.30",
"Microsoft.NuGet.Build.Tasks": "1.0.0-alpha-000001"
},
"frameworks": {
"netcoreapp1.0": {

View file

@ -0,0 +1,42 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.IO;
using FluentAssertions;
using Microsoft.DotNet.Tools.Test.Utilities;
using Xunit;
namespace Microsoft.DotNet.Cli.Build3.Tests
{
public class GivenDotnetBuild3BuildsCsproj : TestBase
{
[Fact]
public void It_builds_a_runnable_output()
{
var testAppName = "MSBuildTestApp";
var testInstance = TestAssetsManager
.CreateTestInstance(testAppName)
.WithLockFiles();
var testProjectDirectory = testInstance.TestRoot;
var build3Command = new TestCommand("dotnet");
build3Command.WorkingDirectory = testProjectDirectory;
build3Command.ExecuteWithCapturedOutput("build3")
.Should()
.Pass();
var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
var outputDll = Path.Combine(testProjectDirectory, "bin", configuration, "netcoreapp1.0", $"{testAppName}.dll");
var outputRunCommand = new TestCommand("dotnet");
outputRunCommand.ExecuteWithCapturedOutput(outputDll)
.Should()
.Pass()
.And
.HaveStdOutContaining("Hello World");
}
}
}

View file

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

View file

@ -0,0 +1,24 @@
{
"version": "1.0.0-*",
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"System.Runtime.Serialization.Primitives": "4.1.1",
"Microsoft.DotNet.Tools.Tests.Utilities": {
"target": "project"
},
"xunit": "2.1.0",
"dotnet-test-xunit": "1.0.0-rc2-192208-24"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.4",
"portable-net451+win8"
]
}
},
"testRunner": "xunit"
}