dotnet icon indicating copy to clipboard operation
dotnet copied to clipboard

[BUG] Resizetizer file access issues on Windows build in Visual Studio in CommunityToolkit.Mvvm 8.2.2

Open SuperCorks opened this issue 1 year ago • 11 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

  • [X] I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug

Current Behavior

Recently I’ve been encountering this error with Resizetizer on build.

Severity	Code	Description	Project	File	Line	Suppression State
Error		Access to the path 'C:\Milliman\DEVL\MOBILE\MAUI\Milliman.Benefits\Milliman.Benefits\obj\Debug\net8.0-android\resizetizer\r\drawable\settings.png' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
   at System.IO.File.OpenFile(String path, FileAccess access, SafeFileHandle& handle)
   at System.IO.File.SetLastWriteTimeUtc(String path, DateTime lastWriteTimeUtc)
   at Microsoft.Maui.Resizetizer.ResizetizeImages.ExecuteAsync() in D:\a\_work\1\s\src\SingleProject\Resizetizer\src\ResizetizeImages.cs:line 105
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()	Milliman.Benefits	C:\Users\simon\.nuget\packages\microsoft.maui.resizetizer\8.0.40\buildTransitive\Microsoft.Maui.Resizetizer.After.targets	631	

This error started occuring a few builds after I updated to 17.9.7. I also get this error with 17.10 preview 7.

If I run dotnet build from the terminal alone I still get this error, but if I run dotnet clean before the build works fine. In visual studio the build never works even if I clean before. I tried rolling back to 17.9.6 and I still get the issue. See me reproducing the issue here: https://www.loom.com/share/8b4c17162bb54005a710a191a9e5d07c?sid=aede5d34-10f7-4f3c-ada2-29a17331b2e1

I also tried copying the project in another directory, same issue.

I'm also notiticing this only happens with .png files. Not svgs.

Expected Behavior

Build's successfully in visual studio for windows.

Steps To Reproduce

  1. Open the project attached here.
  2. Build for Android or iOS

test-issue.zip

Link to public reproduction project repository

Attached to this issue

Environment

- .NET MAUI CommunityToolkit.Mvvm: 8.2.2 (apparently it also happens with CommunityToolkit.Maui 9.0.0)
- OS: Windows 11 (Visual Studio)
- .NET MAUI: Latest

Anything else?

I opened an issue with the Visual Studio team: https://developercommunity.visualstudio.com/t/MAUI---Resizetizer-files-access-to-the-p/10662058

SuperCorks avatar May 28 '24 23:05 SuperCorks

The workaround is reverting to

  • CommunityToolkit.Mvvm 8.0.0
  • CommunityToolkit.Maui 8.0.1

SuperCorks avatar May 28 '24 23:05 SuperCorks

I suspect there is an issue in the .NET MAUI tooling and one of the versions of Visual Studio that you updated to brought that version of the workload in. Downgrading Visual Studio won't fix that.

You could try forcing the specific version of .NET MAUI to be something lower than the latest.

The issue sounds like the tooling is trying to resize your pngs which is something it shouldn't - this should only happen for SVGs. This is what makes me believe it is a tooling issue.

bijington avatar May 29 '24 04:05 bijington

Should we close this and OP can reopen it in the MAUI repo?

Sergio0694 avatar May 29 '24 10:05 Sergio0694

Ok thank you guys

SuperCorks avatar May 29 '24 12:05 SuperCorks

@SuperCorks are you happy to open an issue on the .NET MAUI repository? If so can you link it here just for traceability to help others that might encounter the same issue?

@Sergio0694 that sounds good to me, I don't have the power to do so.

bijington avatar May 29 '24 18:05 bijington

Yes I'll do it before end of week

SuperCorks avatar May 29 '24 19:05 SuperCorks

This issue (at least for me) seems to be when images are readonly because they are not checked out in TFS. My work around is to just keep the image files checked out.

MarkKananen avatar Aug 12 '24 19:08 MarkKananen

I can confirm that @MarkKananen is 100% correct. The issue for me was caused by Team Foundation Server making the source files read-only when they are not checked out. Whatever process copies the source files into the /obj/ directory preserves that read-only attribute and causes the Resizetizer to fail. Checking out the app's resource images removes the read-only attribute from the source images, and the build process succeeds. The version of CommunityToolkit.Maui has no bearing on the success or failure when TFS is the cause.

@SuperCorks Did you end up opening an issue on the .NET MAUI repo? Can you link it here?

MadManMarkAu avatar Aug 23 '24 03:08 MadManMarkAu

I did. Here it is https://github.com/dotnet/maui/issues/23397

SuperCorks avatar Aug 27 '24 17:08 SuperCorks

Hi, i updated a net8.0 maui app to net9.0 and i'm encountering this error. i'm not using TFS

my previous related packages were: <PackageVersion Include="CommunityToolkit.Maui" Version="8.0.1" /> <PackageVersion Include="CommunityToolkit.Mvvm" Version="8.3.2" />

and currents are: <PackageVersion Include="CommunityToolkit.Maui" Version="11.1.0" /> <PackageVersion Include="CommunityToolkit.Mvvm" Version="8.4.0" />

projet009 avatar Feb 27 '25 11:02 projet009

I can confirm the original issue is resolved after updating Visual Studio 2022 to the latest version.

MadManMarkAu avatar May 19 '25 06:05 MadManMarkAu