Honor NoBuild flag during publish
This commit is contained in:
parent
b3eecf0d46
commit
8e23eb38b4
|
|
@ -396,7 +396,7 @@ Copyright (c) .NET Foundation. All rights reserved.
|
|||
Name="_RazorPrepareForPublish"
|
||||
AfterTargets="PrepareForPublish"
|
||||
DependsOnTargets="RazorCompile"
|
||||
Condition="'$(ResolvedRazorCompileToolset)'=='RazorSdk' and '$(RazorCompileOnPublish)'=='true'">
|
||||
Condition="'$(ResolvedRazorCompileToolset)'=='RazorSdk' and '$(RazorCompileOnPublish)'=='true' and '$(NoBuild)'!='true'">
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
|||
}
|
||||
}
|
||||
|
||||
public static void FileExists(MSBuildResult result, params string[] paths)
|
||||
public static string FileExists(MSBuildResult result, params string[] paths)
|
||||
{
|
||||
if (result == null)
|
||||
{
|
||||
|
|
@ -233,6 +233,8 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
|||
{
|
||||
throw new FileMissingException(result, filePath);
|
||||
}
|
||||
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public static void FileCountEquals(MSBuildResult result, int expected, string directoryPath, string searchPattern)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -401,5 +402,45 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
|||
Assert.FileExists(result, PublishOutputPath, "ClassLibrary2.Views.dll");
|
||||
Assert.FileExists(result, PublishOutputPath, "ClassLibrary2.Views.pdb");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[InitializeTestProject("SimpleMvc")]
|
||||
public async Task Publish_WithNoBuild_FailsWithoutBuild()
|
||||
{
|
||||
// Publish without building shouldn't succeed.
|
||||
var result = await DotnetMSBuild("Publish", "/p:NoBuild=true");
|
||||
|
||||
Assert.BuildFailed(result);
|
||||
Assert.BuildError(result, "MSB3030"); // Could not copy the file "obj/Debug/netcoreapp2.2/SimpleMvc.dll because it couldn't be found.
|
||||
|
||||
Assert.FileDoesNotExist(result, PublishOutputPath, "SimpleMvc.dll");
|
||||
Assert.FileDoesNotExist(result, PublishOutputPath, "SimpleMvc.Views.dll");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[InitializeTestProject("SimpleMvc")]
|
||||
public async Task Publish_WithNoBuild_CopiesAlreadyCompiledViews()
|
||||
{
|
||||
// Build
|
||||
var result = await DotnetMSBuild("Build", "/p:AssemblyVersion=1.1.1.1");
|
||||
|
||||
Assert.BuildPassed(result);
|
||||
var assemblyPath = Assert.FileExists(result, OutputPath, "SimpleMvc.dll");
|
||||
var viewsAssemblyPath = Assert.FileExists(result, OutputPath, "SimpleMvc.Views.dll");
|
||||
var assemblyVersion = AssemblyName.GetAssemblyName(assemblyPath).Version;
|
||||
var viewsAssemblyVersion = AssemblyName.GetAssemblyName(viewsAssemblyPath).Version;
|
||||
|
||||
// Publish should copy dlls from OutputPath
|
||||
result = await DotnetMSBuild("Publish", "/p:NoBuild=true");
|
||||
|
||||
Assert.BuildPassed(result);
|
||||
var publishAssemblyPath = Assert.FileExists(result, PublishOutputPath, "SimpleMvc.dll");
|
||||
var publishViewsAssemblyPath = Assert.FileExists(result, PublishOutputPath, "SimpleMvc.Views.dll");
|
||||
var publishAssemblyVersion = AssemblyName.GetAssemblyName(publishAssemblyPath).Version;
|
||||
var publishViewsAssemblyVersion = AssemblyName.GetAssemblyName(publishViewsAssemblyPath).Version;
|
||||
|
||||
Assert.Equal(assemblyVersion, publishAssemblyVersion);
|
||||
Assert.Equal(viewsAssemblyVersion, publishViewsAssemblyVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue