Fix build breaks and some 'build' tests.

This commit is contained in:
Sridhar Periyasamy 2016-02-11 15:55:37 -08:00
parent f86952cf1d
commit 96e425f8bb
17 changed files with 156 additions and 22 deletions

View file

@ -0,0 +1,17 @@
// 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.Diagnostics;
namespace TestApp
{
public class Program
{
public static int Main(string[] args)
{
Console.WriteLine(TestLibrary.Helper.GetMessage());
return 100;
}
}
}

View file

@ -0,0 +1,20 @@
<?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>58808bbc-371e-47d6-a3d0-4902145eda4e</ProjectGuid>
<RootNamespace>TestApp</RootNamespace>
<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>

View file

@ -0,0 +1,22 @@
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"dependencies": {
"TestLibrary": { "target":"project", "version":"1.0.0-*" },
"NETStandard.Library": "1.0.0-rc2-23811"
},
"frameworks": {
"dnxcore50": { }
},
"scripts": {
"prepublish" : ["echo prepublish_output ?%publish:ProjectPath%? ?%publish:Configuration%? ?%publish:OutputPath%? ?%publish:Framework%? ?%publish:Runtime%?"],
"postpublish" : ["echo postpublish_output ?%publish:ProjectPath%? ?%publish:Configuration%? ?%publish:OutputPath%? ?%publish:Framework%? ?%publish:Runtime%?"]
}
}

View file

@ -0,0 +1,24 @@
// 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;
namespace TestLibrary
{
public static class Helper
{
/// <summary>
/// Gets the message from the helper. This comment is here to help test XML documentation file generation, please do not remove it.
/// </summary>
/// <returns>A message</returns>
public static string GetMessage()
{
return "This string came from the test library!";
}
public static void SayHi()
{
Console.WriteLine("Hello there!");
}
}
}

View file

@ -0,0 +1,19 @@
<?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>947dd232-8d9b-4b78-9c6a-94f807d2dd58</ProjectGuid>
<RootNamespace>TestLibrary</RootNamespace>
<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>

View file

@ -0,0 +1,15 @@
{
"version": "1.0.0-*",
"compilationOptions": {
"nowarn": [ "CS1591" ],
"xmlDoc": true,
"additionalArguments": [ "-highentropyva+" ]
},
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23808"
},
"frameworks": {
"dnxcore50": { }
}
}

View file

@ -0,0 +1,3 @@
{
"projects": [ "."]
}

View file

@ -44,8 +44,10 @@ namespace Microsoft.DotNet.TestFramework
.Where(dir => .Where(dir =>
{ {
dir = dir.ToLower(); dir = dir.ToLower();
return !dir.EndsWith("\\bin") && !dir.Contains("\\bin\\") return !dir.EndsWith($"{Path.DirectorySeparatorChar}bin")
&& !dir.EndsWith("\\obj") && !dir.Contains("\\obj\\"); && !dir.Contains($"{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}")
&& !dir.EndsWith($"{Path.DirectorySeparatorChar}obj")
&& !dir.Contains($"{Path.DirectorySeparatorChar}obj{Path.DirectorySeparatorChar}");
}); });
foreach (string sourceDir in sourceDirs) foreach (string sourceDir in sourceDirs)
@ -58,7 +60,8 @@ namespace Microsoft.DotNet.TestFramework
{ {
file = file.ToLower(); file = file.ToLower();
return !file.EndsWith("project.lock.json") return !file.EndsWith("project.lock.json")
&& !file.Contains("\\bin\\") && !file.Contains("\\obj\\"); && !file.Contains($"{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}")
&& !file.Contains($"{Path.DirectorySeparatorChar}obj{Path.DirectorySeparatorChar}");
}); });
foreach (string srcFile in sourceFiles) foreach (string srcFile in sourceFiles)
@ -84,8 +87,10 @@ namespace Microsoft.DotNet.TestFramework
.Where(dir => .Where(dir =>
{ {
dir = dir.ToLower(); dir = dir.ToLower();
return dir.EndsWith("\\bin") || dir.Contains("\\bin\\") return dir.EndsWith($"{Path.DirectorySeparatorChar}bin")
|| dir.EndsWith("\\obj") || dir.Contains("\\obj\\"); || dir.Contains($"{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}")
|| dir.EndsWith($"{Path.DirectorySeparatorChar}obj")
|| dir.Contains($"{Path.DirectorySeparatorChar}obj{Path.DirectorySeparatorChar}");
}); });
foreach (string dirPath in binDirs) foreach (string dirPath in binDirs)
@ -97,7 +102,8 @@ namespace Microsoft.DotNet.TestFramework
.Where(file => .Where(file =>
{ {
file = file.ToLower(); file = file.ToLower();
return file.Contains("\\bin\\") || file.Contains("\\obj\\"); return file.Contains($"{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}")
|| file.Contains($"{Path.DirectorySeparatorChar}obj{Path.DirectorySeparatorChar}");
}); });
foreach (string binFile in binFiles) foreach (string binFile in binFiles)

View file

@ -63,18 +63,18 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
[Theory] [Theory]
// global.json exists // global.json exists
[InlineData(true, null, null, "TestLibrary/bin/Debug/{fw}", "TestApp/bin/Debug/{fw}", "TestApp/bin/Debug/{fw}/{rid}")] [InlineData("1", true, null, null, "TestLibrary/bin/Debug/{fw}", "TestApp/bin/Debug/{fw}", "TestApp/bin/Debug/{fw}/{rid}")]
[InlineData(true, "out", null, "TestLibrary/bin/Debug/{fw}", "TestApp/bin/Debug/{fw}", "out")] [InlineData("2", true, "out", null, "TestLibrary/bin/Debug/{fw}", "TestApp/bin/Debug/{fw}", "out")]
[InlineData(true, null, "build", "build/TestLibrary/bin/Debug/{fw}", "build/TestApp/bin/Debug/{fw}", "build/TestApp/bin/Debug/{fw}/{rid}")] [InlineData("3", true, null, "build", "build/TestLibrary/bin/Debug/{fw}", "build/TestApp/bin/Debug/{fw}", "build/TestApp/bin/Debug/{fw}/{rid}")]
[InlineData(true, "out", "build", "build/TestLibrary/bin/Debug/{fw}", "build/TestApp/bin/Debug/{fw}", "out")] [InlineData("4", true, "out", "build", "build/TestLibrary/bin/Debug/{fw}", "build/TestApp/bin/Debug/{fw}", "out")]
//no global.json //no global.json
//[InlineData(false, null, null, "TestLibrary/bin/debug/{fw}", "TestApp/bin/debug/{fw}", "TestApp/bin/debug/{fw}/{rid}")] //[InlineData(false, null, null, "TestLibrary/bin/debug/{fw}", "TestApp/bin/debug/{fw}", "TestApp/bin/debug/{fw}/{rid}")]
//[InlineData(false, "out", null, "TestLibrary/bin/debug/{fw}", "TestApp/bin/debug/{fw}", "out")] //[InlineData(false, "out", null, "TestLibrary/bin/debug/{fw}", "TestApp/bin/debug/{fw}", "out")]
//[InlineData(false, null, "build", "build/TestLibrary/bin/debug/{fw}", "build/TestApp/bin/debug/{fw}", "build/TestApp/bin/debug/{fw}/{rid}")] //[InlineData(false, null, "build", "build/TestLibrary/bin/debug/{fw}", "build/TestApp/bin/debug/{fw}", "build/TestApp/bin/debug/{fw}/{rid}")]
//[InlineData(false, "out", "build", "build/TestLibrary/bin/debug/{fw}", "build/TestApp/bin/debug/{fw}", "out")] //[InlineData(false, "out", "build", "build/TestLibrary/bin/debug/{fw}", "build/TestApp/bin/debug/{fw}", "out")]
public void DefaultPaths(bool global, string outputValue, string baseValue, string expectedLibCompile, string expectedAppCompile, string expectedAppRuntime) public void DefaultPaths(string testIdentifer, bool global, string outputValue, string baseValue, string expectedLibCompile, string expectedAppCompile, string expectedAppRuntime)
{ {
var testInstance = TestAssetsManager.CreateTestInstance("TestAppWithLibrary", callingMethod: ) var testInstance = TestAssetsManager.CreateTestInstance("TestAppWithLibrary", identifier: testIdentifer)
.WithLockFiles(); .WithLockFiles();
GetProjectInfo(testInstance.TestRoot); GetProjectInfo(testInstance.TestRoot);
@ -96,6 +96,10 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
[Fact] [Fact]
public void ResourceTest() public void ResourceTest()
{ {
var testInstance = TestAssetsManager.CreateTestInstance("TestAppWithLibrary")
.WithLockFiles();
GetProjectInfo(testInstance.TestRoot);
var names = new[] var names = new[]
{ {
"uk-UA", "uk-UA",

View file

@ -58,7 +58,7 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
File.SetLastWriteTimeUtc(file, DateTime.UtcNow); File.SetLastWriteTimeUtc(file, DateTime.UtcNow);
} }
protected CommandResult BuildProject(bool defaultOutput = false, bool noIncremental = false, bool expectBuildFailure = false) protected CommandResult BuildProject(bool noIncremental = false, bool expectBuildFailure = false)
{ {
var mainProjectFile = GetProjectFile(MainProject); var mainProjectFile = GetProjectFile(MainProject);
return BuildProject(mainProjectFile, noIncremental, expectBuildFailure); return BuildProject(mainProjectFile, noIncremental, expectBuildFailure);

View file

@ -75,7 +75,7 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
File.Delete(lockFile); File.Delete(lockFile);
Assert.False(File.Exists(lockFile)); Assert.False(File.Exists(lockFile));
buildResult = BuildProject(expectBuildFailure : true); buildResult = BuildProject(expectBuildFailure: true);
Assert.Contains("does not have a lock file", buildResult.StdErr); Assert.Contains("does not have a lock file", buildResult.StdErr);
} }

View file

@ -14,19 +14,18 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
private const string LibraryProject = "TestLibrary"; private const string LibraryProject = "TestLibrary";
private const string AppProject = "TestApp"; private const string AppProject = "TestApp";
public IncrementalTestsTransitiveRuntime() : base( public IncrementalTestsTransitiveRuntime()
Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects", "TestAppWithTransitiveAppDependency"),
"TestAppWithTransitiveAppDependency",
"This string came from the test library!" + Environment.NewLine)
{ {
Root.CopyDirectory(Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects", LibraryProject)); MainProject = "TestLibrary2";
Root.CopyDirectory(Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects", AppProject)); ExpectedOutput = "This string came from the test library!" + Environment.NewLine;
Root.CopyDirectory(Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects", TestLibraryWithAppDependency));
} }
[Fact] [Fact]
public void TestSkipsRebuildWithTransitiveExeDependency() public void TestSkipsRebuildWithTransitiveExeDependency()
{ {
var testInstance = TestAssetsManager.CreateTestInstance("TestAppWithTransitiveAppDependency")
.WithLockFiles();
TestProjectRoot = testInstance.TestRoot;
var buildResult = BuildProject(); var buildResult = BuildProject();
buildResult.Should().HaveCompiledProject(MainProject); buildResult.Should().HaveCompiledProject(MainProject);
buildResult.Should().HaveCompiledProject(TestLibraryWithAppDependency); buildResult.Should().HaveCompiledProject(TestLibraryWithAppDependency);
@ -40,5 +39,10 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
buildResult.Should().HaveSkippedProjectCompilation(AppProject); buildResult.Should().HaveSkippedProjectCompilation(AppProject);
buildResult.Should().HaveSkippedProjectCompilation(LibraryProject); buildResult.Should().HaveSkippedProjectCompilation(LibraryProject);
} }
protected override string GetProjectDirectory(string projectName)
{
return Path.Combine(TestProjectRoot, projectName);
}
} }
} }

View file

@ -22,7 +22,7 @@
"content": [ "content": [
"../../TestAssets/TestProjects/TestLibraryWithAnalyzer/*", "../../TestAssets/TestProjects/TestLibraryWithAnalyzer/*",
"../../TestAssets/TestProjects/TestLibrary/*", "../../TestAssets/TestProjects/TestAppWithLibrary/TestLibrary/*",
"../../TestAssets/TestProjects/TestProjectWithCultureSpecificResource/*", "../../TestAssets/TestProjects/TestProjectWithCultureSpecificResource/*",
"../../TestAssets/TestProjects/global.json" "../../TestAssets/TestProjects/global.json"
], ],