GithubHelp home page GithubHelp logo

Comments (10)

filzrev avatar filzrev commented on September 24, 2024 1

I've tried to use Roslyn 4.9.0-3.23612.11 (It requires .NET preview NuGet feed).
And It can be successfully running dotnet metadata command.

So this issue will be resolved when Roslyn v4.9.0 is officially released Expected on Feb '24.

from docfx.

filzrev avatar filzrev commented on September 24, 2024 1

On my environment.
Following warning message is displayed before CS0246 errors.

warning: [Failure] Msbuild failed when processing the file 'C:\projects\Rx.NET\Source\src\System.Reactive\System.Reactive.csproj' with message: The specified language targets for uap10.0.18362 is missing. Ensure correct tooling is installed for 'uap'. Missing: 'C:\Program Files\dotnet\sdk\8.0.202\Microsoft\WindowsXaml\v17.0\Microsoft.Windows.UI.Xaml.CSharp.targets'

Above message path indicating .NET SDK version of MSBuild is selected from $(MSBuildExtensionsPath) .
It should use Visual Studio version of MSBuild host instead when generating UWP app metadata.

I've checked how Roslyn 4.9.2 or later execute analysis out-of-process. (dotnet/roslyn#70469)
But can't find ways to change behaviors.

from docfx.

filzrev avatar filzrev commented on September 24, 2024 1

But can't find ways to change behaviors.

BuildHost process kind selection logics are hardcoded at https://github.com/dotnet/roslyn/blob/0d1f9fea04892d9e65e9a780bb773a4d5ed18f8e/src/Workspaces/Core/MSBuild/MSBuild/BuildHostProcessManager.cs#L278-L336.

So when using SDK style projects.
.NET SDK version of MSBuild seems used always.


As a workaround.
It can be resolved by manually importing Microsoft.Windows.UI.Xaml.CSharp.targets file when running docfx metadata command for UWP.

Steps

  1. Add following lines at end of NmeaParser.csproj
  <Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets"
          Condition="'$(TargetFramework)' == 'uap10.0.18362' AND '$(DocfxBuild)' == 'true'" />
  1. Edit docfx.config and change settings for UWP metadata generation.
"properties": {
        "TargetFrameworks": "uap10.0.18362",
        "DocfxBuild": "true", 
        "MSBuildExtensionsPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Preview\\MSBuild"
      },

Note: MSBuild path is depends on VS edition and installed paths.

I don't have Xamarin.Android/Xamarin.iOS build environment thought.
It'll be resolved similar changes.

from docfx.

dotMorten avatar dotMorten commented on September 24, 2024

I'm starting to think the reason is because it can't find Visual Studio because that code isn't included in netcoreapp targets:
https://github.com/microsoft/MSBuildLocator/blob/02c357a9554bf91db26d97c32559e03bbae41501/src/MSBuildLocator/MSBuildLocator.cs#L343-L360
Probably this issue here: microsoft/MSBuildLocator#152

from docfx.

filzrev avatar filzrev commented on September 24, 2024

As described in linked-issue comment (https://github.com/microsoft/MSBuildLocator/issues/152#issuecomment-1839391035)
It' required to run MSBuild on separate process.

It might be resolved when next Roslyn version(4.9.0) released.
Because MSBuildWorkspace build behavior is changed to running out-of-proc.
https://github.com/dotnet/roslyn/issues/61454#issuecomment-1813193707

from docfx.

yufeih avatar yufeih commented on September 24, 2024

I've tried to use Roslyn 4.9.0-3.23612.11 (It requires .NET preview NuGet feed). And It can be successfully running dotnet metadata command.

So this issue will be resolved when Roslyn v4.9.0 is officially released Expected on Feb '24.

Nice finding! Out of proc execution solves a whole class of problems with msbuild.

from docfx.

dotMorten avatar dotMorten commented on September 24, 2024

@yufeih how was this addressed? With 2.76.0 I'm not able to build UWP projects and getting this warning right before all the errors:

warning: [Failure] Msbuild failed when processing the file 'e:\GitHub\dotMorten\NmeaParser\src\NmeaParser\NmeaParser.csproj' with message: If you are building projects that require targets from full MSBuild or MSBuildFrameworkToolsPath, you need to use desktop msbuild ('msbuild.exe') instead of 'dotnet build' or 'dotnet msbuild'

from docfx.

filzrev avatar filzrev commented on September 24, 2024

If you are building projects that require targets from full MSBuild or MSBuildFrameworkToolsPath, you need to use desktop msbuild ('msbuild.exe') instead of 'dotnet build' or 'dotnet msbuild'

Above message is raised by MSBuildExtras package.
It might be resolved by setting "_SdkIgnoreMSBuildCoreWarning": "true"

from docfx.

dotMorten avatar dotMorten commented on September 24, 2024

@filzrev Thanks I tried that both in the project and in the metadata properties, but no luck. I'm getting the same error for UWP, Xamarin.Android and Xamarin.iOS.
Setting the property does get rid of the warning, but not the error. I think all that warning was doing was warning me about what is about to happen:

warning: [Warning] Unresolved metadata reference removed from project: e:\mscorlib.dll
error: c:\myproject\obj\Release\uap10.0.18362\.NETCore,Version=v5.0.AssemblyAttributes.cs(4,20): error CS0400: The type or namespace name 'System' could not be found in the global namespace (are you missing an assembly reference?)
error: c:\myproject\obj\Release\uap10.0.18362\NmeaParser.AssemblyInfo.cs(13,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
error: c:\myproject\obj\Release\uap10.0.18362\NmeaParser.AssemblyInfo.cs(14,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)

from docfx.

dotMorten avatar dotMorten commented on September 24, 2024

@filzrev Thanks for this, but unfortunately this isn't a good solution still because of the hardcoded paths to msbuild, and not everyone is using preview, or enterprise, professional or buildtools versions.
I haven't been able to get it to generate metadata for Xamarin.Android or Xamarin.iOS either since this change, and your solution doesn't work for that (with the import path updated for those).

from docfx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.