Home: GeneratePathProperty not generating path to package, in Visual Studio 2017 (equivalent NuGet.exe/msbuild.exe/dotnet work)

Created on 23 Jul 2019  路  7Comments  路  Source: NuGet/Home

GeneratePath property does not seem to work in my project. I want to be able to copy a documentation file that is in a package to the build output. I found the new GeneratePath property feature. But when i use it in my projectfile as seen below the property just isnt generated.

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

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <AssemblyName>Blabla.Import.Bla.Adapter</AssemblyName>
    <RootNamespace>Blabla.Import.Bla.Adapter</RootNamespace>
  </PropertyGroup>

  <!--Include the stylecop analyzers for the release build -->

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <CodeAnalysisRuleSet>..\_solutionItems\StyleCop.Adapter.ruleset</CodeAnalysisRuleSet>
    <DocumentationFile></DocumentationFile>
  </PropertyGroup>

  <!--Include the stylecop analyzers for the debug build -->

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <CodeAnalysisRuleSet>..\_solutionItems\StyleCop.Adapter.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Blabla.Adapters.Applications" Version="3.0.0-beta20" />
    <PackageReference Include="Blabla.DataServices.Bla" Version="1.0.0" GeneratePathProperty="true" />
    <PackageReference Include="StyleCop.Analyzers.Unstable" Version="1.1.1.94">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
    </PackageReference>

    <None Include="$(PkgBlabla_DataServices_Bla)\contentFiles\any\netcoreapp2.2\Blabla.DataServices.Bla.xml">
      <Link>Blabla.DataServices.Bla.xml</Link>
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>

  <!--include additional solution items -->

  <ItemGroup>
    <None Include="..\_solutionItems\resharper.csproj.DotSettings" Link="properties\ResharperSettings" />
    <None Include="..\_solutionItems\StyleCop.Adapter.ruleset" Link="properties\Stylecop" />
  </ItemGroup>
</Project>

output:
Could not copy the file "D:contentFilesanynetcoreapp2.2Blabla.DataServices.Bla.xml" because it was not found.

Restore PackageReference Investigate

Most helpful comment

Hi, I tried to repro with the following project file, but it copied the Newtonsoft.Json.xml correctly:

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

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Newtonsoft.Json" Version="12.0.2" GeneratePathProperty="true"/>
    <None Include="$(PkgNewtonsoft_Json)\lib\netstandard2.0\Newtonsoft.Json.xml">
      <Link>Newtonsoft.Json.xml</Link>
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>

</Project>

Not sure if the path in your output "D:contentFilesanynetcoreapp2.2Blabla.DataServices.Bla.xml" is right. Can you check the obj/*csproj.nuget.g.props file to see if the $(PkgBlabla_DataServices_Bla) is correct there?

All 7 comments

Hi, I tried to repro with the following project file, but it copied the Newtonsoft.Json.xml correctly:

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

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Newtonsoft.Json" Version="12.0.2" GeneratePathProperty="true"/>
    <None Include="$(PkgNewtonsoft_Json)\lib\netstandard2.0\Newtonsoft.Json.xml">
      <Link>Newtonsoft.Json.xml</Link>
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>

</Project>

Not sure if the path in your output "D:contentFilesanynetcoreapp2.2Blabla.DataServices.Bla.xml" is right. Can you check the obj/*csproj.nuget.g.props file to see if the $(PkgBlabla_DataServices_Bla) is correct there?

Helpful if you tell us which version of the tooling you are using.
Also note that 5.1/16.1 has a bug if the casing in the Include is not equivalent to the casing in the nuspec of the package: https://github.com/NuGet/Home/issues/7843

Hi, I tried to repro with the following project file, but it copied the Newtonsoft.Json.xml correctly:

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

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Newtonsoft.Json" Version="12.0.2" GeneratePathProperty="true"/>
    <None Include="$(PkgNewtonsoft_Json)\lib\netstandard2.0\Newtonsoft.Json.xml">
      <Link>Newtonsoft.Json.xml</Link>
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>

</Project>

Not sure if the path in your output "D:contentFilesanynetcoreapp2.2Blabla.DataServices.Bla.xml" is right. Can you check the obj/*csproj.nuget.g.props file to see if the $(PkgBlabla_DataServices_Bla) is correct there?

Thanks for your response. I tried your example which also isnt working for me. One thing i forgot to mention is that i see a blue squiggly under the pkg name saying that the property is not defined.

image

Am i missing something here? When i check the nuget.g.props inside the obj folder there isnt a pkgnewtonsoft_json reference anywhere? I do however see :

image

So it looks like something similar IS being generated for stylecop.

Note: what i also find strange is that my nuget.g.props has the nugetpackageroot variable declared. But when i try to use $(NuGetPackageRoot) inside my csproj it also says the property is not defined.

Helpful if you tell us which version of the tooling you are using.
Also note that 5.1/16.1 has a bug if the casing in the Include is not equivalent to the casing in the nuspec of the package: #7843

Im not sure which tooling version you are looking for. Anyway this is all the version info i can get out of visual studio:

Microsoft Visual Studio Enterprise 2017
Version 15.9.14
VisualStudio.15.Release/15.9.14+28307.770
Microsoft .NET Framework
Version 4.8.03752

Installed Version: Enterprise

Architecture Diagrams and Analysis Tools 00370-00001-77619-AA254
Microsoft Architecture Diagrams and Analysis Tools

Visual C++ 2017 00370-00001-77619-AA254
Microsoft Visual C++ 2017

Application Insights Tools for Visual Studio Package 8.14.20131.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017 15.9.04012.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services 15.8.31590
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2017 5.2.61435.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 15.9.03024.0
Azure App Service Tools v3.0.0

Azure Data Lake Node 1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio 2.3.3000.2
Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools 15.9.03024.0
Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio 2.3.3000.2
Microsoft Azure Stream Analytics Tools for Visual Studio

C# Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Fabric.DiagnosticEvents 1.0
Fabric Diagnostic Events

ILSpy.AddIn 1.0
Integration of the ILSpy Decompiler into Visual Studio.

JavaScript Language Service 2.0
JavaScript Language Service

JavaScript Project System 2.0
JavaScript Project System

JavaScript UWP Project System 2.0
JavaScript UWP Project System

JetBrains ReSharper Ultimate 2018.3.4 Build 183.0.20190304.43214
JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright 漏 2019 JetBrains, Inc.

Microsoft Azure HDInsight Azure Node 2.3.3000.2
HDInsight Node under Azure Node

Microsoft Azure Hive Query Language Service 2.3.3000.2
Language service for Hive query

Microsoft Azure Service Fabric Tools for Visual Studio 2.5
Microsoft Azure Service Fabric Tools for Visual Studio

Microsoft Azure Stream Analytics Language Service 2.3.3000.2
Language service for Azure Stream Analytics

Microsoft Azure Stream Analytics Node 1.0
Azure Stream Analytics Node under Azure Node

Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.20417.1

Microsoft Continuous Delivery Tools for Visual Studio 0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager 1.0
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio Tools for Containers 1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package

MLGen Package Extension 1.0
MLGen Package Visual Studio Extension Detailed Info

Node.js Tools 1.4.30613.3 Commit Hash:1e6f79a5385c9083fd034ccdfc4f64f58dea9e7b
Adds support for developing and debugging Node.js apps in Visual Studio

NuGet Package Manager 4.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

ResourcePackage Extension 1.0
ResourcePackage Visual Studio Extension Detailed Info

ResourcePackage Extension 1.0
ResourcePackage Visual Studio Extension Detailed Info

SQL Server Data Tools 15.1.61906.03120
Microsoft SQL Server Data Tools

ToolWindowHostedEditor 1.0
Hosting json editor into a tool window

TypeScript Tools 15.9.30524.2002
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.2 for F# 4.5 15.8.0.0. Commit Hash: 6e26c5bacc8c4201e962f5bdde0a177f82f88691.
Microsoft Visual F# Tools 10.2 for F# 4.5

Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Containers 1.0
Visual Studio Tools for Containers

Visual Studio Tools for Universal Windows Apps 15.0.28307.718
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

Hi, thanks for your reply!
Since https://github.com/dotnet/project-system/pull/4226 is only inserted into VS16.x, GeneratePathProperty is not fully supported by VS15.9x.
For VS15.9x, only NuGet and MSbuild command line support this meta data in property. And we're not going to change it in VS15.9x.
So if you can move to VS16.x, the problem will be solved.
Or, you may try if the following workaround works:
1.open vs -> Tools ->NuGet Package Manager -> Package Manager Settings, uncheck two lines under Package Restore.
2.restore the solution by running nuget restore command, or msbuild /t:restore
3.build the solution in any way.

And you will have to change it back for the settings of NuGet Package Manager , as it turns down automatic restore before build in VS, which may cause other problems in future.

Okay thanks for the information. I did not realize this functionality was only supported in VS 2019, i think we will start upgrading to 2019 since this functionality is quite nice to have for what we are trying to do.

Was this page helpful?
0 / 5 - 0 ratings