Failure on edge case; project name ends with '.csproj' #1

Open
opened 2025-09-21 08:36:17 +02:00 by qwsdcvghyu89 · 0 comments
qwsdcvghyu89 commented 2025-09-21 08:36:17 +02:00 (Migrated from github.com)

Summary

If the project name ends with the string '.csproj' and subsequently is placed into a folder structure with '.csproj', and the project file's name ends with '.csproj.csproj', then the following error is produced.

PS C:\Users\qwsdc\source\repos\aeqw89.xml.csproj\aeqw89.xml.csproj> publish increment patch local-packages
Something went wrong loading this file; System.UnauthorizedAccessException: Access to the path 'C:\Users\qwsdc\source\repos\aeqw89.xml.csproj\aeqw89.xml.csproj' is denied.
   at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
   at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy)
   at System.Xml.XmlTextReaderImpl.OpenUrl()
   at System.Xml.XmlTextReaderImpl.Read()
   at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
   at System.Xml.XmlDocument.Load(XmlReader reader)
   at System.Xml.XmlDocument.Load(String filename)
   at aeqw89.tools.Publish.Project.Load(String path)
   at aeqw89.tools.Publish.ProjectFile.TryLoad(String path, ProjectFile& projectFile, String& error)

Replication

  1. Create a new solution with one project, titled "aeqw89.xml.csproj". (or anything that has .csproj at the end)
  2. Unload solution (not necessary, but removes potential for IDE to be locking the project file)
  3. Run in terminal 'publish overwrite local-packages'
### Summary If the project name ends with the string '.csproj' and subsequently is placed into a folder structure with '.csproj', and the project file's name ends with '.csproj.csproj', then the following error is produced. ``` PS C:\Users\qwsdc\source\repos\aeqw89.xml.csproj\aeqw89.xml.csproj> publish increment patch local-packages Something went wrong loading this file; System.UnauthorizedAccessException: Access to the path 'C:\Users\qwsdc\source\repos\aeqw89.xml.csproj\aeqw89.xml.csproj' is denied. at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options) at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode) at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode) at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize) at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy) at System.Xml.XmlTextReaderImpl.OpenUrl() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) at System.Xml.XmlDocument.Load(XmlReader reader) at System.Xml.XmlDocument.Load(String filename) at aeqw89.tools.Publish.Project.Load(String path) at aeqw89.tools.Publish.ProjectFile.TryLoad(String path, ProjectFile& projectFile, String& error) ``` ### Replication 1. Create a new solution with one project, titled "aeqw89.xml.csproj". (or anything that has .csproj at the end) 2. Unload solution (not necessary, but removes potential for IDE to be locking the project file) 3. Run in terminal 'publish overwrite local-packages'
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: riley/aeqw89.tools.Publish#1