Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Support for PackageReferences

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
grigorii_s Posted - Mar 28 2022 : 05:18:37 AM
Hey!

There's one feature of Visual Studio 2022 that I use: It's specifying NuGet packages not in packages.config but directly in project files as <PackageReference/>. A consequence of that is imports of corresponding .props and .targets files are implicit. Imports are placed in generated props and targets files in obj subfolder for each project.

This feature is not officially supported for C++ projects but can be easily enabled.

The downside of using that feature is that Visual Assist knowns nothing about generated props and targets, so it cannot parse includes that correspond to imported packages. Is it possible to support it in Visual Assist?

Regards,
Grigorii
5   L A T E S T    R E P L I E S    (Newest First)
grigorii_s Posted - Apr 01 2022 : 04:36:40 AM
Thank you.

Regards,
Grigorii
feline Posted - Mar 31 2022 : 12:22:24 PM
I have the same project, many thanks for this. I have put in a feature request to pick up packages included like this:

case=148009
feline Posted - Mar 29 2022 : 11:46:39 AM
Can you send me a simple test solution that uses one of these techniques, that works, so I can try to see what you mean?

Adding the first block of code to my VCXPROJ file has stopped the IDE Build menu from showing up when I load that test solution. So that's really not helpful.

For the second method, I don't have any *.props files to modify.

Please send me the files via email:

[email protected]

including this thread ID or URL in the description, so we can match it up.
grigorii_s Posted - Mar 28 2022 : 09:59:04 AM
You need to add following lines to your vcxproj

  <ItemGroup>
    <ProjectCapability Include="PackageReferences" />
  </ItemGroup>
  <PropertyGroup>
    <NuGetTargetMoniker Condition="'$(NuGetTargetMoniker)' == ''">native,Version=v0.0</NuGetTargetMoniker>
    <RuntimeIdentifiers Condition="'$(RuntimeIdentifiers)' == ''">win;win-x86;win-x64;win-arm;win-arm64</RuntimeIdentifiers>
  </PropertyGroup>


Alternatively, you can add them to Directory.Build.props filtering projects by type:


  <ItemGroup Condition="'$(MSBuildProjectExtension)' == '.vcxproj'">
    <ProjectCapability Include="PackageReferences" />
  </ItemGroup>
  <PropertyGroup Condition="'$(MSBuildProjectExtension)' == '.vcxproj'">
    <NuGetTargetMoniker Condition="'$(NuGetTargetMoniker)' == ''">native,Version=v0.0</NuGetTargetMoniker>
    <RuntimeIdentifiers Condition="'$(RuntimeIdentifiers)' == ''">win;win-x86;win-x64;win-arm;win-arm64</RuntimeIdentifiers>
  </PropertyGroup>


After that in Visual Studio 2022 the dialog "Manage NuGet Packages for Solution..." will work as expected for native C++ projects and will add PackageReferences directly into .vcxproj file.

Regards,
Grigorii
feline Posted - Mar 28 2022 : 09:49:15 AM
What do I need to know to set up a test case for this?

Using VS2022 I have created a new, default C++ console solution. Then, based on this page:

https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files

I have added the following block to the .VCXPROJ file:

  <ItemGroup>
     <PackageReference Include="libjpeg" version="9.2.0.1" />
    <PackageReference Include="libjpeg.redist" version="9.2.0.1" />
  </ItemGroup>


I worked out these lines by making a separate C++ console solution in VS2022 and using the dialog:

IDE Tools menu -> NuGet Package Manager -> Manage NuGet Packages for Solution...

to add the package "libjpeg", and then opened the generated file "packages.config" in notepad and copied out the package name and version number details.

The solution where I have used the NuGet package manager dialog works as expected, the package is downloaded and I can include header files from it, and it compiles.

When just trying to add the package information to the VCXPROJ file directly it does not work, no package is downloaded, and trying to reference the package header files doesn't compile.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000