Skip to content

[Vcxproj] Support explicit path to NuGet .targets, and clean up existing packages.config if no longer needed#390

Closed
StripeRose wants to merge 10 commits intoubisoft:mainfrom
StripeRose:main
Closed

[Vcxproj] Support explicit path to NuGet .targets, and clean up existing packages.config if no longer needed#390
StripeRose wants to merge 10 commits intoubisoft:mainfrom
StripeRose:main

Conversation

@StripeRose
Copy link

Context
While attempting to add support for Microsoft.GameInput to my project, I noticed the path to its .targets-file was different to the two paths that were supported by Sharpmake as is. I was unable to find any examples of the same issue being solved previously, or clear ways to alter the path, so I figured adding a way to explicitly define that path could be useful.

Additionally, I noticed the generated packages.config would remain after regenerating the solution having removed all packages from the project.

Description
The change adds a field to supply an explicit .targets-path, which then allows a simplified XML-string to be used to resolve the final .vcxproj line for the import and error. If an explicit path is not defined, the behaviour with the two possible paths is used so previous sharpmake-files still function.

Usage:

conf.ReferencesByNuGetPackage.Add(
	"Microsoft.GameInput",
	"0.2303.22621.3038",
	targetsPath: @"build\native\targets\[packageName].targets"
);

Also changes Vcxproj.GenerateImpl() to run the PackagesConfig generator even if there are no NuGet packages defined, to allow it to clean up existing files that are no longer meant to exist, in case the project is not generated from a clean slate.

Additional info
All regression tests have run fine as far as I can tell, both using the script and via Visual Studio. I couldn't actually locate any specific tests related to vcxproj files though, so I'm uncertain how well covered the changes I've made here are.

StripeRose and others added 9 commits September 14, 2024 15:38
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.7 to 4.2.1.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v4.1.7...v4.2.1)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ke (ubisoft#384)

Bumps [Basic.Reference.Assemblies.Net60](https://github.com/jaredpar/basic-reference-assemblies) from 1.7.8 to 1.7.9.
- [Release notes](https://github.com/jaredpar/basic-reference-assemblies/releases)
- [Commits](jaredpar/basic-reference-assemblies@v1.7.8...v1.7.9)

---
updated-dependencies:
- dependency-name: Basic.Reference.Assemblies.Net60
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Ensures previously created sharpmake scripts don't suddenly stop compiling, and lets them use the default value instead.
@StripeRose
Copy link
Author

Closing this PR since a better solution was merged with #399

I've not quite managed to that one work - there's some issue with the packages don't get added to the *.nuget.g.targets file - but the sample works so it's probably something in my project setup I haven't figured out yet.

@StripeRose StripeRose closed this Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant