secrets.xml cannot be found at the auto-generated path

606 Views Asked by At

I'm trying to use a local secrets.xml file but an error tells me that it can't be found.

I right-clicked on the project and selected 'Manage User Secrets, which created the GUID-named folder and file for me. That same GUID appears in the userSecretsId attribute as below...

<configBuilders>
  <builders>
    <add name="Secrets" optional="false" userSecretsId="[a GUID]" type="..." />
  </builders>
</configBuilders>

But at runtime an exception shows that the file cannot be found.

I then switched to using userSecretsFile and pasted a copy of the file to C:\tmp\secrets.xml. This worked.

So I then pasted the path of the auto-generated secrets.xml - i.e....

%APPDATA%\Microsoft\UserSecrets\<userSecretsId>\secrets.xml

...into the userSecretsFile attribute...

<add name="Secrets" optional="false" userSecretsFile="C:\Users\[my username]\AppData\Roaming\Microsoft\UserSecrets\946bd95c-42a4-45da-aad0-a7874c97fd64\secrets.xml" type="..." />

...and still an exception is thrown saying that the file can't be found.

I'm running Visual Studio 2019 with administrator privileges. Why does it appear to be prevented from accessing the file?

0

There are 0 best solutions below