Exporting a template from Visual Studio 2022 fails with "read-only or does not exists" error

Þór Sigurðsson 5 Reputation points
2025-01-16T13:45:00.9233333+00:00

I created a web project, added specific nuget packages for said project, config files and a wee bit of customization. Then I choose Project -> Export Template. I select the project I want exported as a template, Change the template name to a name not including spaces, set the template description, add an icon image and preview image, un-check to automatically import the template and click finish.

Upon finish, I get this error:

User's image

This directory resides on OneDrive - and it's company mandatory - and not changeable in VS2022 (also - why can't I decide on my own where to write the output file?)

I WAS able to export this morning - but after the first export, every attempt since has been unfruitful.

Help?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,439 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Pascal Minvielle 5 Reputation points
    2025-01-21T17:35:32.3+00:00

    Hello, what worked for me was to delete the "My Exported Templates" directory prior exportation of project. Previously i was recreating an empty directory manually but export did not work. So now every time i need to export i delete the directory, it is automatically recreated with the zip inside. Better backup your zip files somewhere else if u need to keep them.

    1 person found this answer helpful.

  2. Tianyu Sun-MSFT 33,271 Reputation points Microsoft Vendor
    2025-01-17T03:46:27.6333333+00:00

    Hi @Þór Sigurðsson ,

    Welcome to Microsoft Q&A forum.

    I noticed that you mentioned that the directory is writable, did you check the corresponding permissions by right-clicking the "My Exported Templates" folder(and its parent folders) => Properties => General tab => Attributes: Read-only (Only applies to files in folder), and switching to Security tab => select the corresponding user => Edit => make sure that the permissions have been correctly assigned(especially for Write permission)?

    User's image

    User's image

    If so, I think you can try to launch VS as administrator and test to export the project template again. Maybe this issue is caused by some limitations about the accounts.

    If you try to delete the "My Exported Templates" folder manually, and then create a same folder, name it My Exported Templates, will it work?

    I also suggest try to reboot your machine and reconnect to your OneDrive, see if it works.

    Besides, can VS successfully create a new project in your OneDrive directory?

    Best Regards,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.