a35ae177ff
- Project dependencies are always built into their specific folders and the main project is the only one that uses the output path and intermediate output path variable. - Publish respects the output path for publish only, not compile as part of publish. This means that publishing multiple runtimes will stomp on each other. So don't do that. We can throw if you specify and output location and you haven't specified a specific combination of RID and framework. Alternatively it should probably just pick the first TFM/RID pair from the lock file. This is similar to how `dotnet run` works. - Cleaned up the incremental build output formatting - Use a single stream (output stream) since interleaving them was causing formatting issues (like losing random characters in the middle of outputting things). - Didn't change how pack works, it still preserves the output structure when passing `--output`, this one is worth discussing. We could leave the build output inplace and only move the package to the output location. That's more consistent with how everything else works and can be a follow up PR.
127 lines
No EOL
4 KiB
C#
127 lines
No EOL
4 KiB
C#
// 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.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using Microsoft.DotNet.Cli.Utils;
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
|
using Xunit;
|
|
|
|
namespace Microsoft.DotNet.Tools.Builder.Tests
|
|
{
|
|
public class IncrementalTests : IncrementalTestBase
|
|
{
|
|
|
|
public IncrementalTests() : base(
|
|
Path.Combine("TestProjects", "TestSimpleIncrementalApp"),
|
|
"TestSimpleIncrementalApp",
|
|
"Hello World!" + Environment.NewLine)
|
|
{
|
|
}
|
|
|
|
[Fact]
|
|
public void TestForceIncrementalUnsafe()
|
|
{
|
|
var buildResult = BuildProject();
|
|
AssertProjectCompiled(_mainProject, buildResult);
|
|
|
|
buildResult = BuildProject(forceIncrementalUnsafe: true);
|
|
Assert.Contains("[Forced Unsafe]", buildResult.StdOut);
|
|
}
|
|
|
|
[Fact]
|
|
public void TestRebuildMissingPdb()
|
|
{
|
|
TestDeleteOutputWithExtension("pdb");
|
|
}
|
|
|
|
[Fact]
|
|
public void TestRebuildMissingDll()
|
|
{
|
|
TestDeleteOutputWithExtension("dll");
|
|
}
|
|
|
|
[Fact]
|
|
public void TestRebuildMissingXml()
|
|
{
|
|
TestDeleteOutputWithExtension("xml");
|
|
}
|
|
|
|
[Fact]
|
|
public void TestNoLockFile()
|
|
{
|
|
|
|
var buildResult = BuildProject();
|
|
AssertProjectCompiled(_mainProject, buildResult);
|
|
|
|
var lockFile = Path.Combine(_tempProjectRoot.Path, "project.lock.json");
|
|
Assert.True(File.Exists(lockFile));
|
|
|
|
File.Delete(lockFile);
|
|
Assert.False(File.Exists(lockFile));
|
|
|
|
buildResult = BuildProject(expectBuildFailure : true);
|
|
Assert.Contains("does not have a lock file", buildResult.StdOut);
|
|
}
|
|
|
|
[Fact(Skip="https://github.com/dotnet/cli/issues/980")]
|
|
public void TestRebuildChangedLockFile()
|
|
{
|
|
|
|
var buildResult = BuildProject();
|
|
AssertProjectCompiled(_mainProject, buildResult);
|
|
|
|
var lockFile = Path.Combine(_tempProjectRoot.Path, "project.lock.json");
|
|
TouchFile(lockFile);
|
|
|
|
buildResult = BuildProject();
|
|
AssertProjectCompiled(_mainProject, buildResult);
|
|
}
|
|
|
|
[Fact(Skip="https://github.com/dotnet/cli/issues/980")]
|
|
public void TestRebuildChangedProjectFile()
|
|
{
|
|
|
|
var buildResult = BuildProject();
|
|
AssertProjectCompiled(_mainProject, buildResult);
|
|
|
|
TouchFile(GetProjectFile(_mainProject));
|
|
|
|
buildResult = BuildProject();
|
|
AssertProjectCompiled(_mainProject, buildResult);
|
|
}
|
|
|
|
private void TestDeleteOutputWithExtension(string extension)
|
|
{
|
|
|
|
var buildResult = BuildProject();
|
|
AssertProjectCompiled(_mainProject, buildResult);
|
|
|
|
Reporter.Verbose.WriteLine($"Files in {GetCompilationOutputPath()}");
|
|
foreach (var file in Directory.EnumerateFiles(GetCompilationOutputPath()))
|
|
{
|
|
Reporter.Verbose.Write($"\t {file}");
|
|
}
|
|
|
|
// delete output files with extensions
|
|
foreach (var outputFile in Directory.EnumerateFiles(GetCompilationOutputPath()).Where(f =>
|
|
{
|
|
var fileName = Path.GetFileName(f);
|
|
return fileName.StartsWith(_mainProject, StringComparison.OrdinalIgnoreCase) &&
|
|
fileName.EndsWith(extension, StringComparison.OrdinalIgnoreCase);
|
|
}))
|
|
{
|
|
Reporter.Output.WriteLine($"Deleted {outputFile}");
|
|
|
|
File.Delete(outputFile);
|
|
Assert.False(File.Exists(outputFile));
|
|
}
|
|
|
|
// second build; should get rebuilt since we deleted an output item
|
|
buildResult = BuildProject();
|
|
AssertProjectCompiled(_mainProject, buildResult);
|
|
}
|
|
}
|
|
} |