Pack should pack symbol nupkg
* Update path calculation for BuiltProjectOutputGroupOutput to include full path. This matches the behavior of Microsoft.Common.targets. * Add Razor symbols to DebugSymbolsProjectOutputGroupOutput Fixes #2116
This commit is contained in:
parent
0f1bc0e0bd
commit
5bd650bdd1
|
|
@ -58,6 +58,16 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
RazorCoreCompile
|
RazorCoreCompile
|
||||||
</RazorCompileDependsOn>
|
</RazorCompileDependsOn>
|
||||||
|
|
||||||
|
<BuiltProjectOutputGroupDependsOn>
|
||||||
|
$(BuiltProjectOutputGroupDependsOn);
|
||||||
|
_RazorAddBuiltProjectOutputGroupOutput
|
||||||
|
</BuiltProjectOutputGroupDependsOn>
|
||||||
|
|
||||||
|
<DebugSymbolsProjectOutputGroupDependsOn>
|
||||||
|
$(DebugSymbolsProjectOutputGroupDependsOn);
|
||||||
|
_RazorAddDebugSymbolsProjectOutputGroupOutput
|
||||||
|
</DebugSymbolsProjectOutputGroupDependsOn>
|
||||||
|
|
||||||
<PrepareForBuildDependsOn>
|
<PrepareForBuildDependsOn>
|
||||||
_InitializePreserveCompilationContext;
|
_InitializePreserveCompilationContext;
|
||||||
$(PrepareForBuildDependsOn)
|
$(PrepareForBuildDependsOn)
|
||||||
|
|
@ -337,16 +347,22 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
-->
|
-->
|
||||||
<Target
|
<Target
|
||||||
Name="_RazorAddBuiltProjectOutputGroupOutput"
|
Name="_RazorAddBuiltProjectOutputGroupOutput"
|
||||||
DependsOnTargets="ResolveRazorGenerateInputs"
|
DependsOnTargets="_ResolveRazorTargetPath;ResolveRazorGenerateInputs"
|
||||||
BeforeTargets="BuiltProjectOutputGroup"
|
|
||||||
Condition="'$(ResolvedRazorCompileToolset)'=='RazorSdk' and '$(RazorCompileOnBuild)'=='true'">
|
Condition="'$(ResolvedRazorCompileToolset)'=='RazorSdk' and '$(RazorCompileOnBuild)'=='true'">
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<RazorOutputPath Condition="'$(RazorOutputPath)'==''">$([MSBuild]::EnsureTrailingSlash('$(OutDir)'))</RazorOutputPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup Condition="'@(RazorGenerate)'!= ''">
|
<ItemGroup Condition="'@(RazorGenerate)'!= ''">
|
||||||
<BuiltProjectOutputGroupOutput Include="@(RazorIntermediateAssembly)" FinalOutputPath="$(RazorOutputPath)$(RazorTargetName).dll" />
|
<BuiltProjectOutputGroupOutput Include="%(RazorIntermediateAssembly.FullPath)" FinalOutputPath="$(RazorTargetPath)" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target
|
||||||
|
Name="_RazorAddDebugSymbolsProjectOutputGroupOutput"
|
||||||
|
DependsOnTargets="_ResolveRazorTargetPath;ResolveRazorGenerateInputs"
|
||||||
|
Condition="'$(ResolvedRazorCompileToolset)'=='RazorSdk' and '$(RazorCompileOnBuild)'=='true'">
|
||||||
|
|
||||||
|
<ItemGroup Condition="Exists('@(_RazorDebugSymbolsIntermediatePath)')">
|
||||||
|
<DebugSymbolsProjectOutputGroupOutput Include="%(_RazorDebugSymbolsIntermediatePath.FullPath)" FinalOutputPath="$(RazorTargetDir)$(RazorTargetName).pdb" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Target>
|
</Target>
|
||||||
|
|
@ -414,18 +430,14 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
-->
|
-->
|
||||||
<Target
|
<Target
|
||||||
Name="_RazorCopyFilesToOutputDirectory"
|
Name="_RazorCopyFilesToOutputDirectory"
|
||||||
DependsOnTargets="RazorCompile"
|
DependsOnTargets="_ResolveRazorTargetPath;RazorCompile"
|
||||||
AfterTargets="CopyFilesToOutputDirectory"
|
AfterTargets="CopyFilesToOutputDirectory"
|
||||||
Condition="'$(ResolvedRazorCompileToolset)'=='RazorSdk' and '$(RazorCompileOnBuild)'=='true'">
|
Condition="'$(ResolvedRazorCompileToolset)'=='RazorSdk' and '$(RazorCompileOnBuild)'=='true'">
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<RazorOutputPath Condition="'$(RazorOutputPath)'==''">$([MSBuild]::EnsureTrailingSlash('$(OutDir)'))</RazorOutputPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<!-- Copy the Razor dll -->
|
<!-- Copy the Razor dll -->
|
||||||
<Copy
|
<Copy
|
||||||
SourceFiles="@(RazorIntermediateAssembly)"
|
SourceFiles="@(RazorIntermediateAssembly)"
|
||||||
DestinationFolder="$(RazorOutputPath)"
|
DestinationFiles="$(RazorTargetPath)"
|
||||||
SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
|
SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
|
||||||
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
|
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
|
||||||
Retries="$(CopyRetryCount)"
|
Retries="$(CopyRetryCount)"
|
||||||
|
|
@ -506,6 +518,15 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
for 'Microsoft.AspNetCore.Mvc' in your project. For more information, see https://go.microsoft.com/fwlink/?linkid=868374." />
|
for 'Microsoft.AspNetCore.Mvc' in your project. For more information, see https://go.microsoft.com/fwlink/?linkid=868374." />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="_ResolveRazorTargetPath">
|
||||||
|
<PropertyGroup>
|
||||||
|
<RazorOutputPath Condition="'$(RazorOutputPath)'==''">$([MSBuild]::EnsureTrailingSlash('$(OutDir)'))</RazorOutputPath>
|
||||||
|
<RazorTargetDir>$([MSBuild]::Escape($([MSBuild]::EnsureTrailingSlash($([System.IO.Path]::GetFullPath('$([System.IO.Path]::Combine('$(MSBuildProjectDirectory)', '$(RazorOutputPath)'))'))))))</RazorTargetDir>
|
||||||
|
<!-- Example, c:\MyProjects\MyProject\bin\debug\MyAssembly.Views.dll -->
|
||||||
|
<RazorTargetPath Condition=" '$(RazorTargetPath)' == '' ">$(RazorTargetDir)$(RazorTargetName).dll</RazorTargetPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Target>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(RazorDesignTimeTargets)'==''">
|
<PropertyGroup Condition="'$(RazorDesignTimeTargets)'==''">
|
||||||
<RazorDesignTimeTargets>$(MSBuildExtensionsPath)\Microsoft\VisualStudio\Razor\Microsoft.NET.Sdk.Razor.DesignTime.targets</RazorDesignTimeTargets>
|
<RazorDesignTimeTargets>$(MSBuildExtensionsPath)\Microsoft\VisualStudio\Razor\Microsoft.NET.Sdk.Razor.DesignTime.targets</RazorDesignTimeTargets>
|
||||||
<RazorDesignTimeTargets Condition="!Exists('$(RazorDesignTimeTargets)')">$(MSBuildThisFileDirectory)Microsoft.NET.Sdk.Razor.DesignTime.targets</RazorDesignTimeTargets>
|
<RazorDesignTimeTargets Condition="!Exists('$(RazorDesignTimeTargets)')">$(MSBuildThisFileDirectory)Microsoft.NET.Sdk.Razor.DesignTime.targets</RazorDesignTimeTargets>
|
||||||
|
|
|
||||||
|
|
@ -313,7 +313,9 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void NupkgContains(MSBuildResult result, string nupkgPath, string filePath)
|
// This method extracts the nupkg to a fixed directory path. To avoid the extra work of
|
||||||
|
// cleaning up after each invocation, this method accepts multiple files.
|
||||||
|
public static void NupkgContains(MSBuildResult result, string nupkgPath, params string[] filePaths)
|
||||||
{
|
{
|
||||||
if (result == null)
|
if (result == null)
|
||||||
{
|
{
|
||||||
|
|
@ -325,20 +327,23 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
throw new ArgumentNullException(nameof(nupkgPath));
|
throw new ArgumentNullException(nameof(nupkgPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filePath == null)
|
if (filePaths == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(filePath));
|
throw new ArgumentNullException(nameof(filePaths));
|
||||||
}
|
}
|
||||||
|
|
||||||
nupkgPath = Path.Combine(result.Project.DirectoryPath, nupkgPath);
|
nupkgPath = Path.Combine(result.Project.DirectoryPath, nupkgPath);
|
||||||
FileExists(result, nupkgPath);
|
FileExists(result, nupkgPath);
|
||||||
|
|
||||||
var unzipped = Path.Combine(result.Project.DirectoryPath, "nupkg");
|
var unzipped = Path.Combine(result.Project.DirectoryPath, Path.GetFileNameWithoutExtension(nupkgPath));
|
||||||
ZipFile.ExtractToDirectory(nupkgPath, unzipped);
|
ZipFile.ExtractToDirectory(nupkgPath, unzipped);
|
||||||
|
|
||||||
if (!File.Exists(Path.Combine(unzipped, filePath)))
|
foreach (var filePath in filePaths)
|
||||||
{
|
{
|
||||||
throw new NupkgFileMissingException(result, nupkgPath, filePath);
|
if (!File.Exists(Path.Combine(unzipped, filePath)))
|
||||||
|
{
|
||||||
|
throw new NupkgFileMissingException(result, nupkgPath, filePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,15 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
Assert.NuspecContains(
|
Assert.NuspecContains(
|
||||||
result,
|
result,
|
||||||
Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"),
|
Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"),
|
||||||
$"<file src=\"{Path.Combine("bin", Configuration, "netstandard2.0", "ClassLibrary.Views.dll")}\" " +
|
$"<file src=\"{Path.Combine(Project.DirectoryPath, "bin", Configuration, "netstandard2.0", "ClassLibrary.Views.dll")}\" " +
|
||||||
$"target=\"{Path.Combine("lib", "netstandard2.0", "ClassLibrary.Views.dll")}\" />");
|
$"target=\"{Path.Combine("lib", "netstandard2.0", "ClassLibrary.Views.dll")}\" />");
|
||||||
|
|
||||||
|
Assert.NuspecDoesNotContain(
|
||||||
|
result,
|
||||||
|
Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"),
|
||||||
|
$"<file src=\"{Path.Combine(Project.DirectoryPath, "bin", Configuration, "netstandard2.0", "ClassLibrary.Views.pdb")}\" " +
|
||||||
|
$"target=\"{Path.Combine("lib", "netstandard2.0", "ClassLibrary.Views.pdb")}\" />");
|
||||||
|
|
||||||
Assert.NuspecDoesNotContain(
|
Assert.NuspecDoesNotContain(
|
||||||
result,
|
result,
|
||||||
Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"),
|
Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"),
|
||||||
|
|
@ -38,6 +44,33 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
Path.Combine("lib", "netstandard2.0", "ClassLibrary.Views.dll"));
|
Path.Combine("lib", "netstandard2.0", "ClassLibrary.Views.dll"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[InitializeTestProject("ClassLibrary")]
|
||||||
|
public async Task Pack_WithIncludeSymbols_IncludesRazorPdb()
|
||||||
|
{
|
||||||
|
var result = await DotnetMSBuild("Pack", "/p:RazorCompileOnBuild=true /p:IncludeSymbols=true");
|
||||||
|
|
||||||
|
Assert.BuildPassed(result);
|
||||||
|
|
||||||
|
Assert.NuspecContains(
|
||||||
|
result,
|
||||||
|
Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.symbols.nuspec"),
|
||||||
|
$"<file src=\"{Path.Combine(Project.DirectoryPath, "bin", Configuration, "netstandard2.0", "ClassLibrary.Views.dll")}\" " +
|
||||||
|
$"target=\"{Path.Combine("lib", "netstandard2.0", "ClassLibrary.Views.dll")}\" />");
|
||||||
|
|
||||||
|
Assert.NuspecContains(
|
||||||
|
result,
|
||||||
|
Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.symbols.nuspec"),
|
||||||
|
$"<file src=\"{Path.Combine(Project.DirectoryPath, "bin", Configuration, "netstandard2.0", "ClassLibrary.Views.pdb")}\" " +
|
||||||
|
$"target=\"{Path.Combine("lib", "netstandard2.0", "ClassLibrary.Views.pdb")}\" />");
|
||||||
|
|
||||||
|
Assert.NupkgContains(
|
||||||
|
result,
|
||||||
|
Path.Combine("bin", Configuration, "ClassLibrary.1.0.0.symbols.nupkg"),
|
||||||
|
Path.Combine("lib", "netstandard2.0", "ClassLibrary.Views.dll"),
|
||||||
|
Path.Combine("lib", "netstandard2.0", "ClassLibrary.Views.pdb"));
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[InitializeTestProject("ClassLibrary")]
|
[InitializeTestProject("ClassLibrary")]
|
||||||
public async Task Pack_IncludesRazorFilesAsContent_WhenIncludeRazorContentInPack_IsSet()
|
public async Task Pack_IncludesRazorFilesAsContent_WhenIncludeRazorContentInPack_IsSet()
|
||||||
|
|
@ -53,7 +86,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
Assert.NuspecContains(
|
Assert.NuspecContains(
|
||||||
result,
|
result,
|
||||||
Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"),
|
Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"),
|
||||||
$"<file src=\"{Path.Combine("bin", Configuration, "netstandard2.0", "ClassLibrary.Views.dll")}\" " +
|
$"<file src=\"{Path.Combine(Project.DirectoryPath, "bin", Configuration, "netstandard2.0", "ClassLibrary.Views.dll")}\" " +
|
||||||
$"target=\"{Path.Combine("lib", "netstandard2.0", "ClassLibrary.Views.dll")}\" />");
|
$"target=\"{Path.Combine("lib", "netstandard2.0", "ClassLibrary.Views.dll")}\" />");
|
||||||
|
|
||||||
Assert.NuspecContains(
|
Assert.NuspecContains(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue