Visual Studio Community 2017 Preview

400 views
Skip to first unread message

Sean Creighton

unread,
Aug 16, 2017, 5:12:41 AM8/16/17
to Excel-DNA
Hi

I created an empty Net framework Class Library application then I installed the following addin: 

     ExcelDna.AddIn  0.34.6

I change over the code in Class1.cs to the following:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ExcelDna.Integration;

public static class MyFunctions
{
    [ExcelFunction(Description = "My first .NET function")]
    public static string HelloDna(string name)
    {
        return "Hello " + name;
    }
}

Looking at the props file under the obj directory I can see:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
    <RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
    <RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
    <ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">D:\_CODE\Cshrp\testExcelDna2\testExcelDna2\obj\project.assets.json</ProjectAssetsFile>
    <NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
    <NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">D:\Users\s.creighton\.nuget\packages\</NuGetPackageFolders>
    <NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
    <NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">4.3.0</NuGetToolVersion>
  </PropertyGroup>
  <PropertyGroup>
    <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
  </PropertyGroup>
</Project>


however a few things seem to have gone astray, from the readme file

  1. Added a reference to <package>\lib\ExcelDna.Integration.dll.

  • From the read me file Added a file called <ProjectName>-AddIn.dna to your project
does not appear so




















 

Sean Creighton

unread,
Aug 16, 2017, 5:15:14 AM8/16/17
to Excel-DNA
That went half way through me writing it.......

From the read me

Installing the ExcelDna.AddIn NuGet package into your project has made the following changes:
1. Added a reference to <package>\lib\ExcelDna.Integration.dll.    Does not appear
2. Added a build properties file called ExcelDna.Build.props under your Properties item group. This file allows build customization, and ensures that a copy of <package>\tools\ExcelDna\ExcelDna.xll will be placed in your output directory as 
   <ProjectName>-AddIn.xll. This is the add-in loader for your Excel add-in. No xll in output dir
3. The build targets file in the packages also lets the Excel-DNA packing tool ExcelDnaPack.exe run to create a single-file 
   redistributable, called <ProjectName>-AddIn-packed.xll. 
4. Added a file called <ProjectName>-AddIn.dna to your project, set to be copied to the output directory (same name 
   as the .xll). This is the configuration file for your Excel add-in.     Does not appear
5. Configured <ProjectName>-Addin.dna to load your project library as an add-in library, and pack the compiled library
   into the redistributable.
6. Configured debugging to start Excel and load the <ProjectName>-AddIn.xll.  has not happened

Sean Creighton

unread,
Aug 16, 2017, 5:32:07 AM8/16/17
to Excel-DNA

I guess this is all due to the new way nuget is locating the packages file?

Govert van Drimmelen

unread,
Aug 16, 2017, 5:52:40 AM8/16/17
to exce...@googlegroups.com

Hi Sean,

 

It seems like the Powershell script (called install.ps1) that is part of the NuGet package has not run – that’s how these modification to the project are made. Maybe this is due to some security setting on your computer that prevents the NuGet package PowerShell script from running in your context.

 

I suggest you uninstall the package, then re-install and look at the output window – there might be some clue why the NuGet package manager can’t run the script.

 

-Govert

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at https://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.

Sean Creighton

unread,
Aug 20, 2017, 6:00:45 PM8/20/17
to Excel-DNA



Hi

I think I figured it out, it seems to only execute the ps1 script when you select the Nuget packages to be configured using a packages.config file as opposed to the section in the project file.

This screenshot below shows you the output with each choice. (note I changed my tools/settings to display this, I had had it set to "package reference in the project file" always)





When selecting PackagesReference in the ptoject file


Restoring packages for C:\_CODE\Temp\ClassLibrary2\ClassLibrary2\ClassLibrary2.csproj...
Restoring packages for C:\_CODE\Temp\ClassLibrary2\ClassLibrary2\ClassLibrary2.csproj...
Committing restore...
Generating MSBuild file C:\_CODE\Temp\ClassLibrary2\ClassLibrary2\obj\ClassLibrary2.csproj.nuget.g.props.
Generating MSBuild file C:\_CODE\Temp\ClassLibrary2\ClassLibrary2\obj\ClassLibrary2.csproj.nuget.g.targets.
Writing lock file to disk. Path: C:\_CODE\Temp\ClassLibrary2\ClassLibrary2\obj\project.assets.json
Restore completed in 85.33 ms for C:\_CODE\Temp\ClassLibrary2\ClassLibrary2\ClassLibrary2.csproj.
Successfully installed 'ExcelDna.AddIn 0.34.6' to ClassLibrary2
Successfully installed 'ExcelDna.Integration 0.34.6' to ClassLibrary2
Executing nuget actions took 495.1 ms
Time Elapsed: 00:00:00.6151138
========== Finished ==========



When selecting Packages.Config

Attempting to gather dependency information for package 'ExcelDna.AddIn.0.34.6' with respect to project 'ClassLibrary1', targeting '.NETFramework,Version=v4.6.1'
Gathering dependency information took 1.34 sec
Attempting to resolve dependencies for package 'ExcelDna.AddIn.0.34.6' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'ExcelDna.AddIn.0.34.6'
Resolved actions to install package 'ExcelDna.AddIn.0.34.6'
Retrieving package 'ExcelDna.AddIn 0.34.6' from 'nuget'.
Retrieving package 'ExcelDna.Integration 0.34.6' from 'nuget'.
Adding package 'ExcelDna.Integration.0.34.6' to folder 'C:\NugetPackages'
Added package 'ExcelDna.Integration.0.34.6' to folder 'C:\NugetPackages'
Added package 'ExcelDna.Integration.0.34.6' to 'packages.config'
Executing script file 'C:\NugetPackages\ExcelDna.Integration.0.34.6\tools\install.ps1'...
Starting ExcelDna.Integration install script
Set reference to ExcelDna.Integration to be CopyLocal=false
Completed ExcelDna.Integration install script
Successfully installed 'ExcelDna.Integration 0.34.6' to ClassLibrary1
Adding package 'ExcelDna.AddIn.0.34.6' to folder 'C:\NugetPackages'
Added package 'ExcelDna.AddIn.0.34.6' to folder 'C:\NugetPackages'
Added package 'ExcelDna.AddIn.0.34.6' to 'packages.config'
Executing script file 'C:\NugetPackages\ExcelDna.AddIn.0.34.6\tools\install.ps1'...
Starting ExcelDna.AddIn install script
Creating -AddIn.dna file
Setting startup information in Debug configuration
Adding build targets to the project
Completed ExcelDna.AddIn install script
Successfully installed 'ExcelDna.AddIn 0.34.6' to ClassLibrary1
Executing nuget actions took 12.28 sec
Time Elapsed: 00:00:13.8920332





Govert van Drimmelen

unread,
Aug 20, 2017, 6:34:16 PM8/20/17
to exce...@googlegroups.com
Hi Sean,

That's a very valuable observation - thank you for tracking down this issue.

I believe that it is by design that NuGet is not running the install.ps1 in the PackageReference case, but I don't understand the implications of this breaking NuGet change for our Excel-DNA package yet. It looks like an init.ps1 file can still be run. (Reading at the end of this post: https://blog.nuget.org/20170316/NuGet-now-fully-integrated-into-MSBuild.html and here: https://github.com/NuGet/Home/issues/4942 )

We might need to rework how the NuGet package integrates into the project. This is not something I'm likely to take on myself, so any help would be welcome.

For now I guess we can only say that PackageReference is not supported for the Excel-DNA NuGet package.
Would that be a problem for you (apart from the trouble you've had in discovering this limitation)?

-Govert



From: exce...@googlegroups.com [exce...@googlegroups.com] on behalf of Sean Creighton [sean.cr...@gmail.com]
Sent: 21 August 2017 12:00 AM
To: Excel-DNA
Subject: Re: [ExcelDna] Re: Visual Studio Community 2017 Preview

Sean Creighton

unread,
Aug 21, 2017, 6:43:08 AM8/21/17
to Excel-DNA

Hi Govert

I have taken so much from this project, i'm very glad that you think my small contribution is useful. As for me it is not a limitation as long as I know it is there, I can always work round it.

Thanks 
Sean
To post to this group, send email to exc...@googlegroups.com.

Caio Proiete

unread,
Oct 17, 2017, 9:28:49 PM10/17/17
to exce...@googlegroups.com
Sean, I've added some comments to the GitHub issue on supporting `PackageReference`:
https://github.com/Excel-DNA/ExcelDna/issues/138

Cheers,
Caio Proiete


To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages