Excel-DNA / ExcelDna

Excel-DNA - Free and easy .NET for Excel. This repository contains the core Excel-DNA library.
https://excel-dna.net
zlib License
1.26k stars 270 forks source link

Unable to build project with latest release #661

Open francotiveron opened 6 months ago

francotiveron commented 6 months ago

I create an F# project as per the readme.txt

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Library.fs" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="ExcelDna.AddIn" Version="*-*" />
  </ItemGroup>

</Project>

The version downloaded is 1.8.0-alpha1

Build fails with

Error The target platform should specified as Windows in the project file. For example, net6.0-windows

Then I manually change the project

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net6.0-windows</TargetFramework>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Library.fs" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="ExcelDna.AddIn" Version="*-*" />
  </ItemGroup>

</Project>

now I get 2 build errors

MSB4064 The "RollForward" parameter is not supported by the "CreateExcelAddIn" task loaded from assembly: ExcelDna.AddIn.Tasks, Version=1.1.0.0, Culture=neutral, PublicKeyToken=f225e9659857edbe from the path: C:\Users\franco.tiveron.nuget\packages\exceldna.addin\1.7.0\tools\net452\ExcelDna.AddIn.Tasks.dll. Verify that the parameter exists on the task, the points to the correct assembly, and it is a settable public instance property. NinjaTrader.Excel C:\Users\franco.tiveron.nuget\packages\exceldna.addin\1.8.0-alpha1\build\ExcelDna.AddIn.targets 256

MSB4063 The "CreateExcelAddIn" task could not be initialized with its input parameters. NinjaTrader.Excel C:\Users\franco.tiveron.nuget\packages\exceldna.addin\1.8.0-alpha1\build\ExcelDna.AddIn.targets 231

Finally I downgrade to the latest stable

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net6.0-windows</TargetFramework>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Library.fs" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="ExcelDna.AddIn" Version="1.7.0" />
  </ItemGroup>

</Project>

Now the build succeeds and I can debug (F5). however. no -packed.xll files are in the output folder

govert commented 6 months ago

I get this error from time to time too, when changing the NuGet package version. What happens is that the build tasks that run are still taken from the old NuGet package - I presume because of some caching in Visual Studio or a build process. You can see the version is wrong by looking at the directory of the ExcelDna.AddIn.Tasks.dll file - still showing 1.7.0 in the problem build.

Restarting Visual Studio normally fixes this - though sometimes I have to wait or kill the VBCSCompiler process.

If anyone has more information about this annoying bug I'd be happy to hear.