Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VCTargetsPath not set, cannot resolve Projectfile #6013

Open
DSinMeliodas opened this issue Jan 8, 2021 · 4 comments
Open

VCTargetsPath not set, cannot resolve Projectfile #6013

DSinMeliodas opened this issue Jan 8, 2021 · 4 comments
Labels
has-repro There is a sample project, or steps to reproduce the issue. triaged

Comments

@DSinMeliodas
Copy link

Hi,
I've tried to read properties of a C++ Project to evaluate the sdk paths that are used in this project. The first issue I encountered was that the environment variable VCTargetsPath wasn't set so the .cpp.props and .cpp.targets files couldn't be resolved which resulted in an exception. I fixed this by setting the environment variable temporarily by code but doesn't seem to me like clean code so I search for a better way to do this but didn't find one so is there a better way to solve this?

@benvillalobos benvillalobos added the needs-triage Have yet to determine what bucket this goes in. label Jan 13, 2021
@benvillalobos
Copy link
Member

Team Triage: We'll need more information to help you on this:

  • Can you provide an example project that reproduces this behavior?
  • Can you share your build logs?
  • What version of msbuild are you on? (run msbuild -version on a developer command prompt)

It looks like VCTargetsPath should be set like so (in app.config):

src\MSBuild\app.config
106:        <property name="VCTargetsPath" value="$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\Microsoft\VC\v160\'))" />
107:        <property name="VCTargetsPath14" value="$([MSBuild]::ValueOrDefault('$(VCTargetsPath14)','$([MSBuild]::GetProgramFiles32())\MSBuild\Microsoft.Cpp\v4.0\V140\'))" />
108:        <property name="VCTargetsPath12" value="$([MSBuild]::ValueOrDefault('$(VCTargetsPath12)','$([MSBuild]::GetProgramFiles32())\MSBuild\Microsoft.Cpp\v4.0\V120\'))" />
109:        <property name="VCTargetsPath11" value="$([MSBuild]::ValueOrDefault('$(VCTargetsPath11)','$([MSBuild]::GetProgramFiles32())\MSBuild\Microsoft.Cpp\v4.0\V110\'))" />
110:        <property name="VCTargetsPath10" value="$([MSBuild]::ValueOrDefault('$(VCTargetsPath10)','$([MSBuild]::GetProgramFiles32())\MSBuild\Microsoft.Cpp\v4.0\'))" />

@DSinMeliodas
Copy link
Author

MSBuild Version:

Microsoft (R) Build Engine version 16.7.0+b89cb5fde for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
16.7.0.37604

Example Project and Binary Log.zip

@benvillalobos benvillalobos added the has-repro There is a sample project, or steps to reproduce the issue. label Jan 21, 2021
@Forgind
Copy link
Member

Forgind commented Jul 2, 2021

I'm not sure if the underlying cause is the same, but I made a C++ console app, then created a makefile project that was supposed to call it via dotnet build <path to .sln> and tried to build that. It failed with an error about not finding C:\Microsoft.Cpp.Default.props, which suggests VCTargetsPath wasn't set.

@benvillalobos benvillalobos removed the needs-triage Have yet to determine what bucket this goes in. label Jul 29, 2021
@benvillalobos
Copy link
Member

Team Triage: We're guessing you have multiple instances of VS installed, MSBuildLocator.RegisterDefaults() isn't what you want to use in this case. You'll want to call MSBuildLocator.QueryVisualStudioInstances() and MSBuildLocator.RegisterInstance on the one you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has-repro There is a sample project, or steps to reproduce the issue. triaged
Projects
None yet
Development

No branches or pull requests

4 participants