1

I am currently in the process of moving my company's shared class library projects from project references to NuGet package references. I have had success converting all projects except one, which is an older VB.NET project targeting .NET v4.7.2. I get no errors during build or pack and the package is created successfully, but there are a series of external DLLs and the PDB file I need copied into the NuGet package.

Here is the .nuspec file:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
  <metadata>
    <id>Project.Core</id>
    <version>$version$</version>
    <title>$title$</title>
    <authors>Author Here</authors>
    <owners>Owner Here</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>$description$</description>
    <releaseNotes>Initial release.</releaseNotes>
    <copyright>Copyright © 2019</copyright>
  </metadata>

  <files>
    <file src="bin\$configuration$\Project.Core.pdb" target="lib\net472" />
    <file src="bin\$configuration$\FirstExternal.dll" target="lib\net472" />
    <file src="bin\$configuration$\SecondExternal.dll" target="lib\net472" />
    <file src="bin\$configuration$\ThirdExternal.dll" target="lib\net472" />
    <file src="bin\$configuration$\FourthExternal.dll" target="lib\net472" />
    <file src="bin\$configuration$\FifthExternal.dll" target="lib\net472" />
    <file src="bin\$configuration$\SixthExternal.dll" target="lib\net472" />
  </files>
</package>

and here is the project file:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}</ProjectGuid>
    <OutputType>Library</OutputType>
    <RootNamespace>
    </RootNamespace>
    <AssemblyName>Project.Core</AssemblyName>
    <Description>Core Class Library.</Description>
    <MyType>Windows</MyType>
    <SignAssembly>true</SignAssembly>
    <AssemblyOriginatorKeyFile>AssemblyKey.snk</AssemblyOriginatorKeyFile>
    <DelaySign>false</DelaySign>
    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
    <MapFileExtensions>true</MapFileExtensions>
    <UseApplicationTrust>false</UseApplicationTrust>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <DefineDebug>true</DefineDebug>
    <DefineTrace>true</DefineTrace>
    <OutputPath>bin\Debug\</OutputPath>
    <DocumentationFile>Project.Core.xml</DocumentationFile>
    <NoWarn>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42353,42354,42355</NoWarn>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <CodeAnalysisRuleSet>..\StyleCop-Recommended.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>none</DebugType>
    <DefineTrace>true</DefineTrace>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DocumentationFile>Project.Core.xml</DocumentationFile>
    <NoWarn>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42353,42354,42355</NoWarn>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <CodeAnalysisRuleSet>..\..\StyleCop-Recommended.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>

{Some more configuration definitions.}

  <PropertyGroup>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  </PropertyGroup>
  <ItemGroup>

    {Bunch of NuGet references.}

    <Reference Include="FirstExternal">
      <HintPath>..\Lib\FirstExternal\FirstExternal.dll</HintPath>
    </Reference>
    <Reference Include="SecondExternal, Version=1.2.2389.14294, Culture=neutral, PublicKeyToken=60064b713d9de8f4, processorArchitecture=MSIL">
      <HintPath>..\Lib\SecondExternal\1.2\SecondExternal.dll</HintPath>
      <SpecificVersion>False</SpecificVersion>
      <Private>True</Private>
    </Reference>
    <Reference Include="ThirdExternal, Version=11.1.0.0, Culture=neutral, PublicKeyToken=6d02be8724ca751c, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\Lib\ThirdExternal\6.5\ThirdExternal.dll</HintPath>
    </Reference>
    <Reference Include="FourthExternal, Version=6.4.0.0, Culture=neutral, PublicKeyToken=6d02be8724ca751c, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\Lib\FourthExternal\6.5\FourthExternal.dll</HintPath>
    </Reference>
    <Reference Include="FifthExternal, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\Lib\FifthExternal\2.0.5\FifthExternal.dll</HintPath>
    </Reference>
    <Reference Include="SixthExternal">
      <HintPath>..\Lib\SixthExternal\0.3.5_projectCustom\SixthExternal.dll</HintPath>
    </Reference>


    <Reference Include="System" />
    <Reference Include="System.ComponentModel.DataAnnotations" />
    <Reference Include="System.configuration" />
    <Reference Include="System.Core">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Data" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.EnterpriseServices" />
    <Reference Include="System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
    <Reference Include="System.Runtime.Serialization">
      <RequiredTargetFramework>3.0</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.ServiceModel">
      <RequiredTargetFramework>3.0</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Transactions" />
    <Reference Include="System.Web" />
    <Reference Include="System.Web.ApplicationServices" />
    <Reference Include="System.Web.Extensions" />
    <Reference Include="System.Web.Services" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Xml.Linq" />
  </ItemGroup>
  <ItemGroup>
    <Import Include="Microsoft.VisualBasic" />
    <Import Include="System" />
    <Import Include="System.Collections" />
    <Import Include="System.Collections.Generic" />
    <Import Include="System.Data" />
    <Import Include="System.Diagnostics" />
    <Import Include="System.Linq" />
    <Import Include="System.Windows.Forms.ComponentModel.Com2Interop" />
  </ItemGroup>
  <ItemGroup Label="CodeFiles">
    {Lots and lots of compile elements.}
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Include="My Project\Resources.resx">
      <Generator>VbMyResourcesResXFileCodeGenerator</Generator>
      <CustomToolNamespace>My.Resources</CustomToolNamespace>
      <SubType>Designer</SubType>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <LastGenOutput>Resources.Designer.vb</LastGenOutput>
    </EmbeddedResource>
    <EmbeddedResource Include="Resources\Messages.resx">
      <SubType>Designer</SubType>
    </EmbeddedResource>
  </ItemGroup>
  <ItemGroup>
    <None Include="packages.config" />
    <None Include="My Project\Application.myapp">
      <Generator>MyApplicationCodeGenerator</Generator>
      <LastGenOutput>Application.Designer.vb</LastGenOutput>
    </None>
    <None Include="My Project\Settings.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
      <CustomToolNamespace>My</CustomToolNamespace>
      <LastGenOutput>Settings.Designer.vb</LastGenOutput>
    </None>
  </ItemGroup>
  <ItemGroup>
    <WebReferences Include="Web References\" />
  </ItemGroup>
  <ItemGroup>
    <WCFMetadata Include="Service References\" />
  </ItemGroup>
  <ItemGroup>
    <Folder Include="Folder\SubFolder\" />
  </ItemGroup>
  <Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
</Project>

I run the following command: nuget pack .\Path\To\Project\Project.vbproj -Properties Configuration=Debug -OutputDirectory E:\Local\Nuget-Repo -Verbosity detailed but only the DLL for the project and the documentation XML file are put into the lib\net472 folder of the nupkg.

Keep in mind, this project pre-dates my time at the company by a long long time. So there may be very old elements in the project file I am not familiar with.

NuGet Version: 5.0.2.5988
Microsoft (R) Build Engine version 16.1.76+g14b0a930a7 for .NET Framework

Please let me know if there is any extra information needed.

0

I setup a fresh new VB.NET project and tested the pack command with essentially the same .nuspec file and it worked just fine.

Upon further investigation, I found that the project file name has to match the .nuspec file name exactly. I renamed my .nuspec file to match the name of my project file and it works now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.