diff --git a/TestAssets/DesktopTestProjects/DesktopAppWithNativeDep/project.json b/TestAssets/DesktopTestProjects/DesktopAppWithNativeDep/project.json
index ab5874964..8503296a6 100644
--- a/TestAssets/DesktopTestProjects/DesktopAppWithNativeDep/project.json
+++ b/TestAssets/DesktopTestProjects/DesktopAppWithNativeDep/project.json
@@ -1,7 +1,8 @@
{
"version": "1.0.0-*",
"dependencies": {
- "PackageWithFakeNativeDep": "1.0.0-*"
+ "PackageWithFakeNativeDep": "1.0.0-*",
+ "Microsoft.NETCore.Platforms": "1.0.0-rc2-24008"
},
"compilationOptions": {
"emitEntryPoint": true
diff --git a/TestAssets/DesktopTestProjects/DesktopKestrelSample/KestrelDesktop/project.json b/TestAssets/DesktopTestProjects/DesktopKestrelSample/KestrelDesktop/project.json
index 68a974973..e3cc576a0 100644
--- a/TestAssets/DesktopTestProjects/DesktopKestrelSample/KestrelDesktop/project.json
+++ b/TestAssets/DesktopTestProjects/DesktopKestrelSample/KestrelDesktop/project.json
@@ -3,7 +3,8 @@
"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.Extensions.Logging.Console": "1.0.0-rc2-20254",
+ "Microsoft.NETCore.Platforms": "1.0.0-rc2-24008"
},
"compilationOptions": {
"emitEntryPoint": true
diff --git a/TestAssets/DesktopTestProjects/DesktopKestrelSample/KestrelDesktopForce32/.noautobuild b/TestAssets/DesktopTestProjects/DesktopKestrelSample/KestrelDesktopForce32/.noautobuild
new file mode 100644
index 000000000..e69de29bb
diff --git a/TestAssets/DesktopTestProjects/DesktopKestrelSample/KestrelDesktopForce32/project.json b/TestAssets/DesktopTestProjects/DesktopKestrelSample/KestrelDesktopForce32/project.json
new file mode 100644
index 000000000..266055480
--- /dev/null
+++ b/TestAssets/DesktopTestProjects/DesktopKestrelSample/KestrelDesktopForce32/project.json
@@ -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": { }
+ }
+}
diff --git a/TestAssets/DesktopTestProjects/DesktopKestrelSample/KestrelDesktopWithRuntimes/project.json b/TestAssets/DesktopTestProjects/DesktopKestrelSample/KestrelDesktopWithRuntimes/project.json
index 0acc2c505..8ccc5081d 100644
--- a/TestAssets/DesktopTestProjects/DesktopKestrelSample/KestrelDesktopWithRuntimes/project.json
+++ b/TestAssets/DesktopTestProjects/DesktopKestrelSample/KestrelDesktopWithRuntimes/project.json
@@ -3,7 +3,8 @@
"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.Extensions.Logging.Console": "1.0.0-rc2-20254",
+ "Microsoft.NETCore.Platforms": "1.0.0-rc2-24008"
},
"compilationOptions": {
"emitEntryPoint": true
@@ -15,6 +16,7 @@
"net451": { }
},
"runtimes": {
+ "win7-x86": {},
"win7-x64": {},
"osx.10.11-x64": {}
}
diff --git a/TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.xproj b/TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.xproj
index 7811e7531..f115e2bc5 100644
--- a/TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.xproj
+++ b/TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.xproj
@@ -9,9 +9,8 @@
c26a48bb-193f-450c-ab09-4d3324c78188
dotnet-dependency-tool-invoker
..\..\..\artifacts\obj\$(MSBuildProjectName)
- ..\..\..\artifacts\bin\$(MSBuildProjectName)\
+ ..\..\..\artifacts\
-
2.0
diff --git a/TestAssets/TestProjects/TestAppWithArgs/TestAppWithArgs.xproj b/TestAssets/TestProjects/TestAppWithArgs/TestAppWithArgs.xproj
index fbd214cbd..9a39a775b 100644
--- a/TestAssets/TestProjects/TestAppWithArgs/TestAppWithArgs.xproj
+++ b/TestAssets/TestProjects/TestAppWithArgs/TestAppWithArgs.xproj
@@ -9,9 +9,8 @@
da8e0e9e-a6d6-4583-864c-8f40465e3a48
TestAppWithArgs
..\..\..\artifacts\obj\$(MSBuildProjectName)
- ..\..\..\artifacts\bin\$(MSBuildProjectName)\
+ ..\..\..\artifacts\
-
2.0
diff --git a/TestAssets/TestProjects/TestAppWithContents/TestAppWithContents.xproj b/TestAssets/TestProjects/TestAppWithContents/TestAppWithContents.xproj
index 00103e020..fa06ff0b3 100644
--- a/TestAssets/TestProjects/TestAppWithContents/TestAppWithContents.xproj
+++ b/TestAssets/TestProjects/TestAppWithContents/TestAppWithContents.xproj
@@ -9,9 +9,8 @@
0138cb8f-4aa9-4029-a21e-c07c30f425ba
TestAppWithContents
..\..\..\artifacts\obj\$(MSBuildProjectName)
- ..\..\..\artifacts\bin\$(MSBuildProjectName)\
+ ..\..\..\artifacts\
-
2.0
diff --git a/src/Microsoft.DotNet.Compiler.Common/Executable.cs b/src/Microsoft.DotNet.Compiler.Common/Executable.cs
index 89878dbe9..ac4862b1b 100644
--- a/src/Microsoft.DotNet.Compiler.Common/Executable.cs
+++ b/src/Microsoft.DotNet.Compiler.Common/Executable.cs
@@ -16,6 +16,7 @@ using Microsoft.Extensions.DependencyModel;
using NuGet.Frameworks;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
+using System.Reflection.PortableExecutable;
namespace Microsoft.Dotnet.Cli.Compiler.Common
{
diff --git a/src/Microsoft.DotNet.TestFramework/Microsoft.DotNet.TestFramework.TestInstance.cs b/src/Microsoft.DotNet.TestFramework/Microsoft.DotNet.TestFramework.TestInstance.cs
index f6c66d7a6..8912c13ee 100644
--- a/src/Microsoft.DotNet.TestFramework/Microsoft.DotNet.TestFramework.TestInstance.cs
+++ b/src/Microsoft.DotNet.TestFramework/Microsoft.DotNet.TestFramework.TestInstance.cs
@@ -44,9 +44,9 @@ namespace Microsoft.DotNet.TestFramework
.Where(dir =>
{
dir = dir.ToLower();
- return !dir.EndsWith($"{Path.DirectorySeparatorChar}bin")
+ return !dir.EndsWith($"{Path.DirectorySeparatorChar}bin")
&& !dir.Contains($"{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}")
- && !dir.EndsWith($"{Path.DirectorySeparatorChar}obj")
+ && !dir.EndsWith($"{Path.DirectorySeparatorChar}obj")
&& !dir.Contains($"{Path.DirectorySeparatorChar}obj{Path.DirectorySeparatorChar}");
});
diff --git a/src/dotnet/commands/dotnet-build/CompileContext.cs b/src/dotnet/commands/dotnet-build/CompileContext.cs
index d231dd33e..2a9ff80bc 100644
--- a/src/dotnet/commands/dotnet-build/CompileContext.cs
+++ b/src/dotnet/commands/dotnet-build/CompileContext.cs
@@ -108,10 +108,10 @@ namespace Microsoft.DotNet.Tools.Build
{
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;
}
-
+
var compilerIO = GetCompileIO(project, dependencies);
// rebuild if empty inputs / outputs
@@ -189,7 +189,7 @@ namespace Microsoft.DotNet.Tools.Build
return true;
}
-
+
private bool CLIChangedSinceLastCompilation(ProjectContext project)
{
var currentVersionFile = DotnetFiles.VersionFile;
@@ -207,7 +207,9 @@ namespace Microsoft.DotNet.Tools.Build
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;
}
@@ -216,7 +218,7 @@ namespace Microsoft.DotNet.Tools.Build
{
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);
if (!Directory.Exists(parentDirectory))
@@ -224,7 +226,9 @@ namespace Microsoft.DotNet.Tools.Build
Directory.CreateDirectory(parentDirectory);
}
- File.Copy(DotnetFiles.VersionFile, projectVersionFile, true);
+ string content = ComputeCurrentVersionFileData();
+
+ File.WriteAllText(projectVersionFile, content);
}
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)
{
// 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
diff --git a/src/dotnet/commands/dotnet-compile/ManagedCompiler.cs b/src/dotnet/commands/dotnet-compile/ManagedCompiler.cs
index 3177d61df..a21b1be51 100644
--- a/src/dotnet/commands/dotnet-compile/ManagedCompiler.cs
+++ b/src/dotnet/commands/dotnet-compile/ManagedCompiler.cs
@@ -5,11 +5,13 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
+using System.Runtime.InteropServices;
using Microsoft.DotNet.Cli.Compiler.Common;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.ProjectModel.Compilation;
using Microsoft.Extensions.DependencyModel;
+using NuGet.Frameworks;
namespace Microsoft.DotNet.Tools.Compiler
{
@@ -77,6 +79,15 @@ namespace Microsoft.DotNet.Tools.Compiler
};
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 references = new List();
diff --git a/test/Installer/Microsoft.DotNet.Cli.Msi.Tests/Microsoft.DotNet.Cli.Msi.Tests.xproj b/test/Installer/Microsoft.DotNet.Cli.Msi.Tests/Microsoft.DotNet.Cli.Msi.Tests.xproj
index 64ee27ba4..00b0d9710 100644
--- a/test/Installer/Microsoft.DotNet.Cli.Msi.Tests/Microsoft.DotNet.Cli.Msi.Tests.xproj
+++ b/test/Installer/Microsoft.DotNet.Cli.Msi.Tests/Microsoft.DotNet.Cli.Msi.Tests.xproj
@@ -9,7 +9,7 @@
0B31C336-149D-471A-B7B1-27B0F1E80F83
Microsoft.DotNet.Cli.Msi.Tests
..\..\..\artifacts\obj\$(MSBuildProjectName)
- ..\..\..\artifacts\bin\$(MSBuildProjectName)\
+ ..\..\..\artifacts\
2.0
diff --git a/test/dotnet-publish.Tests/PublishDesktopTests.cs b/test/dotnet-publish.Tests/PublishDesktopTests.cs
index 19481e008..752bc27dc 100644
--- a/test/dotnet-publish.Tests/PublishDesktopTests.cs
+++ b/test/dotnet-publish.Tests/PublishDesktopTests.cs
@@ -1,11 +1,14 @@
using System.Diagnostics;
using System.IO;
+using System.Linq;
using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.TestFramework;
using Microsoft.DotNet.Tools.Test.Utilities;
+using Microsoft.Extensions.PlatformAbstractions;
using Xunit;
namespace Microsoft.DotNet.Tools.Publish.Tests
@@ -13,11 +16,16 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
public class PublishDesktopTests : TestBase
{
[WindowsOnlyTheory]
- [InlineData(null, "the-win-x64-version.txt")]
+ [InlineData(null, null)]
[InlineData("win7-x64", "the-win-x64-version.txt")]
[InlineData("win7-x86", "the-win-x86-version.txt")]
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"))
.WithLockFiles();
@@ -33,12 +41,17 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
}
[WindowsOnlyTheory]
- [InlineData("KestrelDesktopWithRuntimes", "http://localhost:20201", null, "libuv.dll", true)]
- [InlineData("KestrelDesktopWithRuntimes", "http://localhost:20202", "win7-x64", "libuv.dll", true)]
- [InlineData("KestrelDesktop", "http://localhost:20204", null, "libuv.dll", true)]
- [InlineData("KestrelDesktop", "http://localhost:20205", "win7-x64", "libuv.dll", true)]
- public async Task DesktopApp_WithKestrel_WorksWhenPublished(string project, string url, string runtime, string libuvName, bool runnable)
+ [InlineData("KestrelDesktopWithRuntimes", "http://localhost:20201", null, "libuv.dll", false)]
+ [InlineData("KestrelDesktopWithRuntimes", "http://localhost:20202", "win7-x64", "libuv.dll", false)]
+ [InlineData("KestrelDesktopWithRuntimes", "http://localhost:20203", "win7-x86", "libuv.dll", false)]
+ [InlineData("KestrelDesktopForce32", "http://localhost:20204", "win7-x86", "libuv.dll", true)]
+ [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()
.WithLockFiles();
@@ -55,7 +68,9 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
Task exec = null;
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
{
exec = command.ExecuteAsync(url);
@@ -74,10 +89,16 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
}
[WindowsOnlyTheory]
- [InlineData("KestrelDesktop", "http://localhost:20207")]
- [InlineData("KestrelDesktopWithRuntimes", "http://localhost:20208")]
+ [InlineData("KestrelDesktop", "http://localhost:20301")]
+ [InlineData("KestrelDesktopWithRuntimes", "http://localhost:20302")]
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()
.WithLockFiles()
.WithBuildArtifacts();
diff --git a/test/dotnet-publish.Tests/project.json b/test/dotnet-publish.Tests/project.json
index 3df76c62b..87a6459ec 100644
--- a/test/dotnet-publish.Tests/project.json
+++ b/test/dotnet-publish.Tests/project.json
@@ -12,7 +12,8 @@
},
"xunit": "2.1.0",
"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": {
"netcoreapp1.0": {