Ensure the project is built in dotnet run3.

This commit is contained in:
Eric Erhardt 2016-09-09 08:49:22 -05:00
parent ab8e1b707b
commit f084032af6
7 changed files with 47 additions and 44 deletions

View file

@ -2,7 +2,7 @@
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {
"dependencies": { "dependencies": {
"Microsoft.NETCore.Sdk": "1.0.0-alpha-20160907-1", "Microsoft.NETCore.Sdk": "1.0.0-alpha-20160909-2",
"Microsoft.NETCore.App": { "Microsoft.NETCore.App": {
"version": "1.0.1", "version": "1.0.1",
"type": "platform" "type": "platform"

View file

@ -5,17 +5,16 @@
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> <Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>6D028154-5518-4A56-BAD6-938A90E5BCF6</ProjectGuid> <ProjectGuid>6D028154-5518-4A56-BAD6-938A90E5BCF6</ProjectGuid>
<RootNamespace>dotnet_test_console</RootNamespace> <RootNamespace>dotnet_test_console</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">obj\$(MSBuildProjectName)</BaseIntermediateOutputPath> <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">bin\$(MSBuildProjectName)\</OutputPath> <OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin</OutputPath>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> <Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project> </Project>

View file

@ -74,6 +74,22 @@ namespace Microsoft.DotNet.Cli
return 1; return 1;
} }
catch (Exception ex)
{
#if DEBUG
Reporter.Error.WriteLine(ex.ToString());
#else
if (Reporter.IsVerbose)
{
Reporter.Error.WriteLine(ex.ToString());
}
else
{
Reporter.Error.WriteLine(ex.Message);
}
#endif
return 1;
}
finally finally
{ {
if (PerfTrace.Enabled) if (PerfTrace.Enabled)

View file

@ -3,7 +3,7 @@
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {
"dependencies": { "dependencies": {
"Microsoft.NETCore.Sdk": "1.0.0-alpha-20160907-1", "Microsoft.NETCore.Sdk": "1.0.0-alpha-20160909-2",
"Microsoft.NETCore.App": { "Microsoft.NETCore.App": {
"type": "platform", "type": "platform",
"version": "1.0.1" "version": "1.0.1"

View file

@ -35,26 +35,7 @@ namespace Microsoft.DotNet.Tools.Run
return runCmd.Start(); return runCmd.Start();
}); });
try return app.Execute(args);
{
return app.Execute(args);
}
catch (Exception ex)
{
#if DEBUG
Reporter.Error.WriteLine(ex.ToString());
#else
if (Reporter.IsVerbose)
{
Reporter.Error.WriteLine(ex.ToString());
}
else
{
Reporter.Error.WriteLine(ex.Message);
}
#endif
return 1;
}
} }
} }
} }

View file

@ -7,6 +7,7 @@ using System.IO;
using System.Linq; using System.Linq;
using Microsoft.Build.Execution; using Microsoft.Build.Execution;
using Microsoft.Build.Framework; using Microsoft.Build.Framework;
using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Cli.Utils;
using NuGet.Frameworks; using NuGet.Frameworks;
@ -37,6 +38,8 @@ namespace Microsoft.DotNet.Tools.Run
{ {
Initialize(); Initialize();
EnsureProjectIsBuilt();
ITaskItem runInfoItem = GetRunInformation(); ITaskItem runInfoItem = GetRunInformation();
string commandName = runInfoItem.GetMetadata("CommandName"); string commandName = runInfoItem.GetMetadata("CommandName");
@ -49,6 +52,27 @@ namespace Microsoft.DotNet.Tools.Run
.ExitCode; .ExitCode;
} }
private void EnsureProjectIsBuilt()
{
List<string> buildArgs = new List<string>();
buildArgs.Add("/nologo");
buildArgs.Add("/verbosity:quiet");
if (!string.IsNullOrWhiteSpace(Configuration))
{
buildArgs.Add($"/p:Configuration={Configuration}");
}
var buildResult = new MSBuildForwardingApp(buildArgs).Execute();
if (buildResult != 0)
{
Reporter.Error.WriteLine();
throw new GracefulException("The build failed. Please fix the build errors and run again.");
}
}
private ITaskItem GetRunInformation() private ITaskItem GetRunInformation()
{ {
Dictionary<string, string> globalProperties = new Dictionary<string, string>() Dictionary<string, string> globalProperties = new Dictionary<string, string>()

View file

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>f003f228-2ae2-4e9d-877b-93eb773b5061</ProjectGuid>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>