make 'platform' flag dependent upon CLI bitness

this will make net451 deployment work for x86 apps
This commit is contained in:
Andrew Stanton-Nurse 2016-04-11 15:56:44 -07:00
parent f2bf60d06f
commit a48596ff23
15 changed files with 94 additions and 28 deletions

View file

@ -1,7 +1,8 @@
{ {
"version": "1.0.0-*", "version": "1.0.0-*",
"dependencies": { "dependencies": {
"PackageWithFakeNativeDep": "1.0.0-*" "PackageWithFakeNativeDep": "1.0.0-*",
"Microsoft.NETCore.Platforms": "1.0.0-rc2-24008"
}, },
"compilationOptions": { "compilationOptions": {
"emitEntryPoint": true "emitEntryPoint": true

View file

@ -3,7 +3,8 @@
"dependencies": { "dependencies": {
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-20113", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-20113",
"Microsoft.AspNetCore.Hosting": "1.0.0-rc2-20113", "Microsoft.AspNetCore.Hosting": "1.0.0-rc2-20113",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-20254" "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-20254",
"Microsoft.NETCore.Platforms": "1.0.0-rc2-24008"
}, },
"compilationOptions": { "compilationOptions": {
"emitEntryPoint": true "emitEntryPoint": true

View file

@ -0,0 +1,19 @@
{
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-20113",
"Microsoft.AspNetCore.Hosting": "1.0.0-rc2-20113",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-20254",
"Microsoft.NETCore.Platforms": "1.0.0-rc2-24008"
},
"compilationOptions": {
"platform": "anycpu32bitpreferred",
"emitEntryPoint": true
},
"compile": [
"../src/*.cs"
],
"frameworks": {
"net451": { }
}
}

View file

@ -3,7 +3,8 @@
"dependencies": { "dependencies": {
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-20113", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-20113",
"Microsoft.AspNetCore.Hosting": "1.0.0-rc2-20113", "Microsoft.AspNetCore.Hosting": "1.0.0-rc2-20113",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-20254" "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-20254",
"Microsoft.NETCore.Platforms": "1.0.0-rc2-24008"
}, },
"compilationOptions": { "compilationOptions": {
"emitEntryPoint": true "emitEntryPoint": true
@ -15,6 +16,7 @@
"net451": { } "net451": { }
}, },
"runtimes": { "runtimes": {
"win7-x86": {},
"win7-x64": {}, "win7-x64": {},
"osx.10.11-x64": {} "osx.10.11-x64": {}
} }

View file

@ -9,9 +9,8 @@
<ProjectGuid>c26a48bb-193f-450c-ab09-4d3324c78188</ProjectGuid> <ProjectGuid>c26a48bb-193f-450c-ab09-4d3324c78188</ProjectGuid>
<RootNamespace>dotnet-dependency-tool-invoker</RootNamespace> <RootNamespace>dotnet-dependency-tool-invoker</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath> <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath> <OutputPath Condition="'$(OutputPath)'=='' ">..\..\..\artifacts\</OutputPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
</PropertyGroup> </PropertyGroup>

View file

@ -9,9 +9,8 @@
<ProjectGuid>da8e0e9e-a6d6-4583-864c-8f40465e3a48</ProjectGuid> <ProjectGuid>da8e0e9e-a6d6-4583-864c-8f40465e3a48</ProjectGuid>
<RootNamespace>TestAppWithArgs</RootNamespace> <RootNamespace>TestAppWithArgs</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath> <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath> <OutputPath Condition="'$(OutputPath)'=='' ">..\..\..\artifacts\</OutputPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
</PropertyGroup> </PropertyGroup>

View file

@ -9,9 +9,8 @@
<ProjectGuid>0138cb8f-4aa9-4029-a21e-c07c30f425ba</ProjectGuid> <ProjectGuid>0138cb8f-4aa9-4029-a21e-c07c30f425ba</ProjectGuid>
<RootNamespace>TestAppWithContents</RootNamespace> <RootNamespace>TestAppWithContents</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath> <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath> <OutputPath Condition="'$(OutputPath)'=='' ">..\..\..\artifacts\</OutputPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
</PropertyGroup> </PropertyGroup>

View file

@ -16,6 +16,7 @@ using Microsoft.Extensions.DependencyModel;
using NuGet.Frameworks; using NuGet.Frameworks;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Reflection.PortableExecutable;
namespace Microsoft.Dotnet.Cli.Compiler.Common namespace Microsoft.Dotnet.Cli.Compiler.Common
{ {

View file

@ -44,9 +44,9 @@ namespace Microsoft.DotNet.TestFramework
.Where(dir => .Where(dir =>
{ {
dir = dir.ToLower(); dir = dir.ToLower();
return !dir.EndsWith($"{Path.DirectorySeparatorChar}bin") return !dir.EndsWith($"{Path.DirectorySeparatorChar}bin")
&& !dir.Contains($"{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}") && !dir.Contains($"{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}")
&& !dir.EndsWith($"{Path.DirectorySeparatorChar}obj") && !dir.EndsWith($"{Path.DirectorySeparatorChar}obj")
&& !dir.Contains($"{Path.DirectorySeparatorChar}obj{Path.DirectorySeparatorChar}"); && !dir.Contains($"{Path.DirectorySeparatorChar}obj{Path.DirectorySeparatorChar}");
}); });

View file

@ -108,10 +108,10 @@ namespace Microsoft.DotNet.Tools.Build
{ {
if (CLIChangedSinceLastCompilation(project)) if (CLIChangedSinceLastCompilation(project))
{ {
Reporter.Output.WriteLine($"Project {project.GetDisplayName()} will be compiled because the CLI changed"); Reporter.Output.WriteLine($"Project {project.GetDisplayName()} will be compiled because the version or bitness of the CLI changed since the last build");
return true; return true;
} }
var compilerIO = GetCompileIO(project, dependencies); var compilerIO = GetCompileIO(project, dependencies);
// rebuild if empty inputs / outputs // rebuild if empty inputs / outputs
@ -189,7 +189,7 @@ namespace Microsoft.DotNet.Tools.Build
return true; return true;
} }
private bool CLIChangedSinceLastCompilation(ProjectContext project) private bool CLIChangedSinceLastCompilation(ProjectContext project)
{ {
var currentVersionFile = DotnetFiles.VersionFile; var currentVersionFile = DotnetFiles.VersionFile;
@ -207,7 +207,9 @@ namespace Microsoft.DotNet.Tools.Build
return false; return false;
} }
var versionsAreEqual = string.Equals(File.ReadAllText(currentVersionFile), File.ReadAllText(versionFileFromLastCompile), StringComparison.OrdinalIgnoreCase); var currentContent = ComputeCurrentVersionFileData();
var versionsAreEqual = string.Equals(currentContent, File.ReadAllText(versionFileFromLastCompile), StringComparison.OrdinalIgnoreCase);
return !versionsAreEqual; return !versionsAreEqual;
} }
@ -216,7 +218,7 @@ namespace Microsoft.DotNet.Tools.Build
{ {
if (File.Exists(DotnetFiles.VersionFile)) if (File.Exists(DotnetFiles.VersionFile))
{ {
var projectVersionFile = project.GetSDKVersionFile(_args.ConfigValue, _args.BuildBasePathValue,_args.OutputValue); var projectVersionFile = project.GetSDKVersionFile(_args.ConfigValue, _args.BuildBasePathValue, _args.OutputValue);
var parentDirectory = Path.GetDirectoryName(projectVersionFile); var parentDirectory = Path.GetDirectoryName(projectVersionFile);
if (!Directory.Exists(parentDirectory)) if (!Directory.Exists(parentDirectory))
@ -224,7 +226,9 @@ namespace Microsoft.DotNet.Tools.Build
Directory.CreateDirectory(parentDirectory); Directory.CreateDirectory(parentDirectory);
} }
File.Copy(DotnetFiles.VersionFile, projectVersionFile, true); string content = ComputeCurrentVersionFileData();
File.WriteAllText(projectVersionFile, content);
} }
else else
{ {
@ -232,6 +236,14 @@ namespace Microsoft.DotNet.Tools.Build
} }
} }
private static string ComputeCurrentVersionFileData()
{
var content = File.ReadAllText(DotnetFiles.VersionFile);
content += Environment.NewLine;
content += PlatformServices.Default.Runtime.GetRuntimeIdentifier();
return content;
}
private void PrintSummary(bool success) private void PrintSummary(bool success)
{ {
// todo: Ideally it's the builder's responsibility for adding the time elapsed. That way we avoid cross cutting display concerns between compile and build for printing time elapsed // todo: Ideally it's the builder's responsibility for adding the time elapsed. That way we avoid cross cutting display concerns between compile and build for printing time elapsed

View file

@ -5,11 +5,13 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices;
using Microsoft.DotNet.Cli.Compiler.Common; using Microsoft.DotNet.Cli.Compiler.Common;
using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.ProjectModel; using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.ProjectModel.Compilation; using Microsoft.DotNet.ProjectModel.Compilation;
using Microsoft.Extensions.DependencyModel; using Microsoft.Extensions.DependencyModel;
using NuGet.Frameworks;
namespace Microsoft.DotNet.Tools.Compiler namespace Microsoft.DotNet.Tools.Compiler
{ {
@ -77,6 +79,15 @@ namespace Microsoft.DotNet.Tools.Compiler
}; };
var compilationOptions = context.ResolveCompilationOptions(args.ConfigValue); var compilationOptions = context.ResolveCompilationOptions(args.ConfigValue);
// Set default platform if it isn't already set and we're on desktop
if(compilationOptions.EmitEntryPoint == true && string.IsNullOrEmpty(compilationOptions.Platform) && context.TargetFramework.IsDesktop())
{
// See https://github.com/dotnet/cli/issues/2428 for more details.
compilationOptions.Platform = RuntimeInformation.ProcessArchitecture == Architecture.X64 ?
"x64" : "anycpu32bitpreferred";
}
var languageId = CompilerUtil.ResolveLanguageId(context); var languageId = CompilerUtil.ResolveLanguageId(context);
var references = new List<string>(); var references = new List<string>();

View file

@ -9,7 +9,7 @@
<ProjectGuid>0B31C336-149D-471A-B7B1-27B0F1E80F83</ProjectGuid> <ProjectGuid>0B31C336-149D-471A-B7B1-27B0F1E80F83</ProjectGuid>
<RootNamespace>Microsoft.DotNet.Cli.Msi.Tests</RootNamespace> <RootNamespace>Microsoft.DotNet.Cli.Msi.Tests</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath> <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath> <OutputPath Condition="'$(OutputPath)'=='' ">..\..\..\artifacts\</OutputPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>

View file

@ -1,11 +1,14 @@
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using FluentAssertions; using FluentAssertions;
using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.TestFramework; using Microsoft.DotNet.TestFramework;
using Microsoft.DotNet.Tools.Test.Utilities; using Microsoft.DotNet.Tools.Test.Utilities;
using Microsoft.Extensions.PlatformAbstractions;
using Xunit; using Xunit;
namespace Microsoft.DotNet.Tools.Publish.Tests namespace Microsoft.DotNet.Tools.Publish.Tests
@ -13,11 +16,16 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
public class PublishDesktopTests : TestBase public class PublishDesktopTests : TestBase
{ {
[WindowsOnlyTheory] [WindowsOnlyTheory]
[InlineData(null, "the-win-x64-version.txt")] [InlineData(null, null)]
[InlineData("win7-x64", "the-win-x64-version.txt")] [InlineData("win7-x64", "the-win-x64-version.txt")]
[InlineData("win7-x86", "the-win-x86-version.txt")] [InlineData("win7-x86", "the-win-x86-version.txt")]
public async Task DesktopApp_WithDependencyOnNativePackage_ProducesExpectedOutput(string runtime, string expectedOutputName) public async Task DesktopApp_WithDependencyOnNativePackage_ProducesExpectedOutput(string runtime, string expectedOutputName)
{ {
if(string.IsNullOrEmpty(expectedOutputName))
{
expectedOutputName = $"the-win-{RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant()}-version.txt";
}
var testInstance = TestAssetsManager.CreateTestInstance(Path.Combine("..", "DesktopTestProjects", "DesktopAppWithNativeDep")) var testInstance = TestAssetsManager.CreateTestInstance(Path.Combine("..", "DesktopTestProjects", "DesktopAppWithNativeDep"))
.WithLockFiles(); .WithLockFiles();
@ -33,12 +41,17 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
} }
[WindowsOnlyTheory] [WindowsOnlyTheory]
[InlineData("KestrelDesktopWithRuntimes", "http://localhost:20201", null, "libuv.dll", true)] [InlineData("KestrelDesktopWithRuntimes", "http://localhost:20201", null, "libuv.dll", false)]
[InlineData("KestrelDesktopWithRuntimes", "http://localhost:20202", "win7-x64", "libuv.dll", true)] [InlineData("KestrelDesktopWithRuntimes", "http://localhost:20202", "win7-x64", "libuv.dll", false)]
[InlineData("KestrelDesktop", "http://localhost:20204", null, "libuv.dll", true)] [InlineData("KestrelDesktopWithRuntimes", "http://localhost:20203", "win7-x86", "libuv.dll", false)]
[InlineData("KestrelDesktop", "http://localhost:20205", "win7-x64", "libuv.dll", true)] [InlineData("KestrelDesktopForce32", "http://localhost:20204", "win7-x86", "libuv.dll", true)]
public async Task DesktopApp_WithKestrel_WorksWhenPublished(string project, string url, string runtime, string libuvName, bool runnable) [InlineData("KestrelDesktop", "http://localhost:20205", null, "libuv.dll", false)]
[InlineData("KestrelDesktop", "http://localhost:20206", "win7-x64", "libuv.dll", false)]
[InlineData("KestrelDesktop", "http://localhost:20207", "win7-x86", "libuv.dll", false)]
public async Task DesktopApp_WithKestrel_WorksWhenPublished(string project, string url, string runtime, string libuvName, bool forceRunnable)
{ {
var runnable = forceRunnable || string.IsNullOrEmpty(runtime) || (PlatformServices.Default.Runtime.GetLegacyRestoreRuntimeIdentifier().Contains(runtime));
var testInstance = GetTestInstance() var testInstance = GetTestInstance()
.WithLockFiles(); .WithLockFiles();
@ -55,7 +68,9 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
Task exec = null; Task exec = null;
if (runnable) if (runnable)
{ {
var command = new TestCommand(Path.Combine(outputDir.FullName, publishCommand.GetOutputExecutable())); var outputExePath = Path.Combine(outputDir.FullName, publishCommand.GetOutputExecutable());
var command = new TestCommand(outputExePath);
try try
{ {
exec = command.ExecuteAsync(url); exec = command.ExecuteAsync(url);
@ -74,10 +89,16 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
} }
[WindowsOnlyTheory] [WindowsOnlyTheory]
[InlineData("KestrelDesktop", "http://localhost:20207")] [InlineData("KestrelDesktop", "http://localhost:20301")]
[InlineData("KestrelDesktopWithRuntimes", "http://localhost:20208")] [InlineData("KestrelDesktopWithRuntimes", "http://localhost:20302")]
public async Task DesktopApp_WithKestrel_WorksWhenRun(string project, string url) public async Task DesktopApp_WithKestrel_WorksWhenRun(string project, string url)
{ {
// Disabled due to https://github.com/dotnet/cli/issues/2428
if (RuntimeInformation.ProcessArchitecture == Architecture.X86)
{
return;
}
var testInstance = GetTestInstance() var testInstance = GetTestInstance()
.WithLockFiles() .WithLockFiles()
.WithBuildArtifacts(); .WithBuildArtifacts();

View file

@ -12,7 +12,8 @@
}, },
"xunit": "2.1.0", "xunit": "2.1.0",
"xunit.netcore.extensions": "1.0.0-prerelease-00206", "xunit.netcore.extensions": "1.0.0-prerelease-00206",
"dotnet-test-xunit": "1.0.0-dev-140469-38" "dotnet-test-xunit": "1.0.0-dev-140469-38",
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0-rc2-24008"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {