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

MSBuild has a grudge against $(VSToolsPath) #6607

Closed
jimmylewis opened this issue Jun 22, 2021 · 2 comments
Closed

MSBuild has a grudge against $(VSToolsPath) #6607

jimmylewis opened this issue Jun 22, 2021 · 2 comments

Comments

@jimmylewis
Copy link
Contributor

Issue Description

Imports using $(VSToolsPath) are ignored by MSBuild. The preprocess step silently comments them out instead of importing the file.

Workaround: use an equivalent value ($(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion) works).

Steps to Reproduce

<Project>
  <Import Project="SDK.props" Sdk="Microsoft.NET.Sdk" />
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>
  <Import Project="SDK.targets" Sdk="Microsoft.NET.Sdk" />
  <Import Project="$(VSToolsPath)\TextTemplating\Microsoft.TextTemplating.targets" />
</Project>

Expected Behavior

I expect Microsoft.TextTemplating.targets to be imported.

Actual Behavior

Output from msbuild /pp:

  <!--
============================================================================================================================================
  </Import>
C:\Users\jamlew\source\repos\T4Setup\T4Setup\T4Setup.csproj
============================================================================================================================================
-->
  <!--<Import Project="$(VSToolsPath)\TextTemplating\Microsoft.TextTemplating.targets" />-->
</Project>

Analysis

Per teams chat:

[8:39 AM] Rainer Sigwald
I have no idea what's going wrong here; please file a bug. I repro but don't know what would cause a silent ignore
​[8:40 AM] Rainer Sigwald
changing $(VSToolsPath) to a constant makes it error, as I would expect
​[8:40 AM] Rainer Sigwald
ah, there's a clue
​[8:40 AM] Rainer Sigwald
we have a fallback from the early Willow days for certain folders
​[8:41 AM] Rainer Sigwald

Search paths being used for $(VSToolsPath) are ;$(MSBuildProgramFiles32)\MSBuild\Microsoft\VisualStudio\v$(VisualStudioVersion)

​[8:43 AM] Rainer Sigwald
ah, it's because there's no definition for VSToolsPath by default, but we have it in projectImportSearchPaths
​[8:43 AM] Rainer Sigwald
we should still error, though, if the fallback doesn't work
​[8:43 AM] Rainer Sigwald
so that's a bug

Versions & Configurations

C:\Program Files\Microsoft Visual Studio\2022\Preview>msbuild -version
Microsoft (R) Build Engine version 17.0.0-preview-21317-11+c579afe9c for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

17.0.0.31711

@jimmylewis jimmylewis added bug needs-triage Have yet to determine what bucket this goes in. labels Jun 22, 2021
@rainersigwald
Copy link
Member

Expounding on my IM stuff:

<property name="VSToolsPath" value="$(MSBuildProgramFiles32)\MSBuild\Microsoft\VisualStudio\v$(VisualStudioVersion)"/>

this should be firing but is not (condition wrong?):

// Found at least one project file for the Import, but no projects were loaded
// atleastOneExactFilePathWasLookedAtAndNotFound would be false, eg, if the expression
// was a wildcard and it resolved to zero files!
if (allProjects.Count == 0 &&
atleastOneExactFilePathWasLookedAtAndNotFound &&
(_loadSettings & ProjectLoadSettings.IgnoreMissingImports) == 0)
{
ThrowForImportedProjectWithSearchPathsNotFound(fallbackSearchPathMatch, importElement);
}

@rainersigwald
Copy link
Member

rainersigwald commented Jun 22, 2021

(I accidentally posted what was meant for #6602 (comment) here, sorry.)

@rainersigwald rainersigwald added this to the 17.0 milestone Jun 22, 2021
@rainersigwald rainersigwald added regression Partner request needs-triage Have yet to determine what bucket this goes in. and removed needs-triage Have yet to determine what bucket this goes in. regression labels Jun 22, 2021
@rainersigwald rainersigwald removed this from the 17.0 milestone Jun 22, 2021
@rainersigwald rainersigwald removed the needs-triage Have yet to determine what bucket this goes in. label Jun 30, 2021
@Forgind Forgind self-assigned this Dec 6, 2022
@Forgind Forgind closed this as completed May 12, 2023
@AR-May AR-May added the triaged label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants