Skip to content

Commit 347fa5b

Browse files
authored
Merge pull request #773 from Excel-DNA/PackPdb
Added support for ExcelAddInIncludePdb project property
2 parents 437e9cc + 9b4929f commit 347fa5b

File tree

9 files changed

+93
-1
lines changed

9 files changed

+93
-1
lines changed

Package/ExcelDna.AddIn/build/ExcelDna.AddIn.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@
265265
ExplicitRegistration="$(ExcelAddInExplicitRegistration)"
266266
ComServer="$(ExcelAddInComServer)"
267267
LoadFromBytes="$(ExcelAddInLoadFromBytes)"
268+
IncludePdb="$(ExcelAddInIncludePdb)"
268269
IntegrationDllPath="$(ExcelDnaRuntimeToolsPath)ExcelDna.Integration.dll"
269270
TemplateDnaPath="$(MSBuildThisFileDirectory)..\content\ExcelDna-Template.dna">
270271
<Output TaskParameter="DnaFilesToPack" ItemName="ExcelDnaFilesToPack" />

Source/ExcelDna.AddIn.Tasks/CreateExcelAddIn.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,9 @@ private string GetDefaultDnaText()
390390
if (!string.IsNullOrWhiteSpace(AddInInclude))
391391
{
392392
string includes = "";
393+
string IncludePdbValue = IncludePdb ? "true" : "false";
393394
foreach (string path in SplitDlls(AddInInclude))
394-
includes += $" <Reference Path=\"{path}\" Pack=\"true\" />" + Environment.NewLine;
395+
includes += $" <Reference Path=\"{path}\" Pack=\"true\" IncludePdb=\"{IncludePdbValue}\" />" + Environment.NewLine;
395396
result = result.Replace("</DnaLibrary>", includes + "</DnaLibrary>");
396397
}
397398

@@ -473,6 +474,9 @@ private string UpdateExternalLibrary(string template, string dllFileName)
473474
if (!LoadFromBytes)
474475
result = result.Replace("LoadFromBytes=\"true\"", "LoadFromBytes=\"false\"");
475476

477+
if (IncludePdb)
478+
result = result.Replace("IncludePdb=\"false\"", "IncludePdb=\"true\"");
479+
476480
return result.Replace("%OutputFileName%", dllFileName);
477481
}
478482

@@ -800,6 +804,11 @@ public string FileSuffix64Bit
800804
/// </summary>
801805
public bool LoadFromBytes { get; set; }
802806

807+
/// <summary>
808+
/// Enable/disable including pdb files in packed add-in
809+
/// </summary>
810+
public bool IncludePdb { get; set; }
811+
803812
/// <summary>
804813
/// The list of .dna files copied to the output
805814
/// </summary>

Source/Tests/ExcelDna.AddIn.Tasks.IntegrationTests.TestTarget/ExcelDna.AddIn.Tasks.IntegrationTests.TestTarget.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NET8RuntimeFrameworkVersion
132132
EndProject
133133
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NET8.Dna", "NET8.Dna\NET8.Dna.csproj", "{33B20965-1561-1FF1-FA16-5B5CCFB3D171}"
134134
EndProject
135+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NET6PackPdb", "NET6PackPdb\NET6PackPdb.csproj", "{153C8664-D61C-77D7-A300-8CED54D130EA}"
136+
EndProject
135137
Global
136138
GlobalSection(SolutionConfigurationPlatforms) = preSolution
137139
Debug|Any CPU = Debug|Any CPU
@@ -394,6 +396,10 @@ Global
394396
{33B20965-1561-1FF1-FA16-5B5CCFB3D171}.Debug|Any CPU.Build.0 = Debug|Any CPU
395397
{33B20965-1561-1FF1-FA16-5B5CCFB3D171}.Release|Any CPU.ActiveCfg = Release|Any CPU
396398
{33B20965-1561-1FF1-FA16-5B5CCFB3D171}.Release|Any CPU.Build.0 = Release|Any CPU
399+
{153C8664-D61C-77D7-A300-8CED54D130EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
400+
{153C8664-D61C-77D7-A300-8CED54D130EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
401+
{153C8664-D61C-77D7-A300-8CED54D130EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
402+
{153C8664-D61C-77D7-A300-8CED54D130EA}.Release|Any CPU.Build.0 = Release|Any CPU
397403
EndGlobalSection
398404
GlobalSection(SolutionProperties) = preSolution
399405
HideSolutionNode = FALSE
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.IO;
3+
using System.Runtime.InteropServices;
4+
using System.Windows.Forms;
5+
using ExcelDna.Integration;
6+
7+
namespace NET6PackPdb
8+
{
9+
public class AddIn : IExcelAddIn
10+
{
11+
public void AutoOpen()
12+
{
13+
var thisAddInName = Path.GetFileName((string)XlCall.Excel(XlCall.xlGetName));
14+
var message = string.Format("Excel-DNA Add-In '{0}' loaded!", thisAddInName);
15+
16+
message += Environment.NewLine;
17+
message += Environment.NewLine;
18+
message += CallStackLibrary.Class1.GetCallStack();
19+
20+
MessageBox.Show(message, thisAddInName, MessageBoxButtons.OK, MessageBoxIcon.Information);
21+
}
22+
23+
public void AutoClose()
24+
{
25+
}
26+
}
27+
}
Binary file not shown.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0-windows</TargetFramework>
5+
<UseWindowsForms>True</UseWindowsForms>
6+
7+
<ExcelAddInIncludePdb>True</ExcelAddInIncludePdb>
8+
<ExcelAddInInclude>CallStackLibrary.dll</ExcelAddInInclude>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<Reference Include="CallStackLibrary">
13+
<HintPath>CallStackLibrary.dll</HintPath>
14+
</Reference>
15+
<Reference Include="ExcelDna.Integration">
16+
<HintPath>..\..\.exceldna.addin\tools\net6.0-windows7.0\ExcelDna.Integration.dll</HintPath>
17+
</Reference>
18+
</ItemGroup>
19+
20+
<Import Project="$(ProjectDir)..\..\.exceldna.addin\build\ExcelDna.AddIn.targets" />
21+
22+
</Project>

Source/Tests/ExcelDna.AddIn.Tasks.IntegrationTests.TestTarget/SDKProperties/SDKProperties.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@
177177
<!-- Default value: true -->
178178
<ExcelAddInLoadFromBytes></ExcelAddInLoadFromBytes>
179179

180+
<!-- Enable/disable including pdb files in packed add-in. -->
181+
<!-- Default value: false -->
182+
<ExcelAddInIncludePdb></ExcelAddInIncludePdb>
183+
180184
<!-- We don't need the extra 'ref' directory and reference assemblies for the Excel add-in -->
181185
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
182186

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using NUnit.Framework;
2+
using System.IO;
3+
4+
namespace ExcelDna.AddIn.Tasks.IntegrationTests
5+
{
6+
[TestFixture]
7+
public class NET6PackPdbTests : IntegrationTestBase
8+
{
9+
[Test]
10+
public void NET6PackPdbTest()
11+
{
12+
const string projectBasePath = @"NET6PackPdb\";
13+
const string projectOutDir = projectBasePath + @"bin\Release\";
14+
15+
Clean(projectOutDir);
16+
17+
MsBuild(projectBasePath + "NET6PackPdb.csproj /t:Restore,Build /p:Configuration=Release /v:m " + MsBuildParam("OutputPath", @"bin\Release\"));
18+
19+
AssertFileContains(Path.Combine(projectOutDir, "NET6PackPdb-AddIn64.dna"), "ExternalLibrary Path=\"NET6PackPdb.dll\" ExplicitExports=\"false\" LoadFromBytes=\"false\" Pack=\"true\" IncludePdb=\"true\"");
20+
AssertFileContains(Path.Combine(projectOutDir, "NET6PackPdb-AddIn64.dna"), "Reference Path=\"CallStackLibrary.dll\" Pack=\"true\" IncludePdb=\"true\"");
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)