System.Exception: Could Not Find File 'C:\Users\USERNAME\.nuget\packages\PROJECT_NAME\PROJECT_VERSION\lib\net45\Main.xaml'

When running the published project from Orchestrator second time after logging off the Robot machine, exception "System.Exception: Could not find file 'C:\Users\USERNAME\.nuget\packages\PROJECT_NAME\PROJECT_VERSION\lib\net45\Main.xaml' is logged.

Issue Description: Below exception occurred when running the published project from Orchestrator second time after logging off the Robot machine: "System.Exception: Could not find file ‘C:\Users\USERNAME.nuget\packages\PROJECT_NAME\PROJECT_VERSION\lib\net45\Main.xaml’

Issue occurs for all the processes. However processes are running fine every time, when running it from Robot tray .


Root Cause: This error (System.Exception: Could not find file ‘C:\Users\USERNAME.nuget\packages\PROJECT_NAME \PROJECT_VERSION\lib\net45\Main.xaml’) generally comes when Robot is not able to find the main.xaml file in the project folder in the Robot machine. Non-persistent nature of VM as “.xaml” files get deleted from userprofile after logging off from the machine.


Resolution: Try the below approaches,

  1. Since the issue is happening after every second run, below is the more probable cause of the issue:
  • Verify the persistent nature of the VM / VDI and follow below steps:
  1. Publish the new version of package and download it manually in the robot machine.
  2. Manually log off the machine.
  3. Log In back and the check files present in path " %Userprofile%.nuget/packages "
  4. If able to see the activities dependencies then open the path present in the above exception
  • ie C:\Users\USERNAME\.nuget\packages\PROJECT_NAME \PROJECT_VERSION\lib\net45 and check if ".xaml" files are present or not.
If ".xaml" files are not present that means VM / VDI is non-persistent in nature or the files present in the user profile and it is suggested to contact local internal IT team to fix it .
  1. If files are present then check the project.json file present in the path mentioned in the exception and check "main" key. Verify if the correct name is present or not.