Language
Edit

MSB3821 diagnostic code

This article describes the MSB3821 error code.

Message text

MSB3821: Couldn't process file 'value' due to its being in the Internet or Restricted zone or having the mark of the web on the file. Remove the mark of the web if you trust these files and want to process them. Please follow MSBuild secure usage best practices - https://aka.ms/msbuild-security-documentation

Description

This error occurs when MSBuild attempts to process a file that has the mark of the web, such as a file downloaded from the web or a cloud drive.

When you download web assets like HTML pages to a Windows device by using a browser, the browser inserts a marker called the mark of the web, which records the security zone of the site from which the page originated. MSBuild requires trusted inputs: you're responsible for trusting the files you build, either by reviewing them fully or by trusting their source. By default, MSBuild doesn't process files that carry the mark of the web, because their content hasn't been established as trusted. Removing the mark indicates that you've decided to trust the file. For more information, see MSBuild secure usage best practices.

Resolution

If you decide to trust the content in question, you can remove the mark of the web by unblocking a single file from File Explorer. Open the Properties window on the file, and select Unblock. You can also unblock multiple files with a PowerShell script and the Unblock-File cmdlet.

If the project is on a virtual disk, such as a Dev Drive backed by a .vhdx file, the virtual disk file itself might have the mark of the web. This situation can occur when you download the virtual disk or copy it from another computer. Windows classifies files on the mounted volume as belonging to the Internet zone, even when the individual files don't have the mark. If you trust the virtual disk and its contents, use Properties or Unblock-File to unblock the backing .vhd or .vhdx file.

Visual Studio also includes security restrictions that detect the mark of the web comment. You can customize trust settings in the Tools > Options pane in the All Settings > Environment > Security > Trust section. For more information, see Configure trust settings for files and folders.

Visual Studio also includes security restrictions that detect the mark of the web comment. You can customize trust settings in the Tools > Options dialog in the Environment > Security section. For more information, see Configure trust settings for files and folders.

In some cases, you can't fix the error directly in Visual Studio. Instead, follow this procedure:

  1. Close Visual Studio.
  2. In File Explorer, go to the project folder.
  3. Locate the file that has the MSB3821 error and open the Properties menu (Alt + Enter).
  4. Select the Unblock checkbox, and then select Apply.
  5. Close the window.
  6. Restart Visual Studio. Open your project, and build the project again.

Applies to

All versions of MSBuild