question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Building the Toolkit Sample project requires Long Path Support to be enabled.

See original GitHub issue

Description

One cannot build the Toolkit Sample project without Enabling Long Path support in windows. It appears that the Source generators are using some sort of mixed Project/TypeName scheme to store output files and avoid name collisions.

I’ve looked but not located any Wiki or other build discussion that mentions the Long Path support requirement. TBH, I didn’t look that hard even after the issue, and I didn’t dig farther than the landing page readme.md when I cloned the project.

One example of many that results from the output of building Project: CommunityToolkit.Maui.Sample:

4>CSC : error CS0016: Could not write to output file 'C:\MauiTesting\Maui\samples\CommunityToolkit.Maui.Sample\obj\GeneratedFiles\CommunityToolkit.Mvvm.SourceGenerators\CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator\CommunityToolkit.Maui.Sample.ViewModels.Converters.EnumToBoolConverterViewModel.cs' -- 'Could not find a part of the path 'C:\MauiTesting\Maui\samples\CommunityToolkit.Maui.Sample\obj\GeneratedFiles\CommunityToolkit.Mvvm.SourceGenerators\CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator\CommunityToolkit.Maui.Sample.ViewModels.Converters.EnumToBoolConverterViewModel.cs'.'

I cloned the project into the default C:\MauiTesting\ folder that VS2022 preview uses as the default project dir. So the root path is just about as small as it gets. Thus C:\MauiTesting\Maui\samples\CommunityToolkit.Maui.Sample\obj is the project contribution to the path and the generator adds:

\GeneratedFiles\CommunityToolkit.Mvvm.SourceGenerators\CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator\CommunityToolkit.Maui.Sample.ViewModels.Converters.EnumToBoolConverterViewModel.cs

While I understand the basic premise here is to avoid name collisions I wonder if the same effect might be observed by removing all the path/folder redirection and sticking with namespace prefixed filenames? In my Source Generator code I inject information about the Generator that created the file using attributes such as: (I’m using Scriban templates here and can provide an example if you’d like)

namespace {{ RootNamespace }}
{
    [ GeneratedCode("{{ GeneratorName }}", "{{ Version }}" ) ]
    [ CompilerGenerated ]
    internal class AGeneratedClass : ISomeInterface

While not an issue for me at the moment some organizations lock users out of OS changes as well which might be a bit of a struggle if the IS organizations are like most I’ve encountered over the years.

Link to Reproduction Sample

Toolkit Sample Project

Steps to Reproduce

  1. Disable Long Path support in windows if you already have it.
  2. Build the sample project.

Expected Behavior

You can build the project without taking extra OS configuration steps.

Actual Behavior

Confusing build errors and Registry edits required to get it to build.

  • IDE: VS2022 17.3.0 Preview 1

Workaround

Enabling Long Path support in windows.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
pictoscommented, May 19, 2022

@bijington will not affect any functionality around VS and generated code. That configuration is there to workaround some issues, at the time that we implemented the SGs, on VS Windows and Mac.

@bakerhillpins yes, you’re right, but at the time that we did the SG that view was broken and on VSMac you can’t see the generated files inside the IDE. We’ll disable that csproj configuration by default to avoid devs to hit this issue.

1reaction
bijingtoncommented, May 19, 2022

@bakerhillpins having read your error message again I can see that the issue is in one of the samples dependencies CommunityToolkit.Mvvm.SourceGenerators and not actually our source generators.

That toolkit is over at: https://github.com/CommunityToolkit/dotnet

This information may be beneficial to them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MSBuild should handle paths longer than MAX_PATH #53
As seen in Fix 260 character file name length limitation, there's quite a bit of support for better longer-than-MAX_PATH-filename handling.
Read more >
Can you enable long-path support for builds?
I have long-path support enabled in Windows, Unreal, and Rider, and everything works fine. But when I try to package my project, I...
Read more >
Long Path Enabled Does not Work
You can do this by opening the Registry Editor (regedit.exe) and navigating to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem.
Read more >
MSI APIs does not support long filenames - How to shorten ...
1 Answer 1 · Press Windows key and tap R , type gpedit.msc and press Enter . · Go to: Local Computer Policy...
Read more >
4.3 Enabling Windows Long Path (Windows 10 - 1803 build)
Navigate to Local Computer Policy > Computer Configuration > Administrative Templates > System > Filesystem. Double click Enable NTFS long paths. Select Enabled...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found