Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UntrustedLocation check #11286

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

JanKrivanek
Copy link
Member

Fixes dotnet/sdk#45342

Context

Building (or just executing targets) under the Downloads folder is not recomended, as uninteded injection of unrelated msbuild logic can happen.

This checks emits error in such case.

Testing

Manual testing

PS C:\Users\jankrivanek\Downloads\mytest\console> C:\src\msbuild-2\artifacts\bin\bootstrap\net472\MSBuild\Current\Bin\MSBuild.exe -check -v:m -restore
MSBuild version 17.14.0-dev-25064-01+a273f56ac for .NET Framework
  Determining projects to restore...
  Restored C:\Users\jankrivanek\Downloads\mytest\console\console.csproj (in 205 ms).
MSBUILD : error BC0301: Location: 'C:\Users\jankrivanek\Downloads\mytest\console' cannot be fully trusted, place your proje
cts outside of that folder (Project: console.csproj).
  console -> C:\Users\jankrivanek\Downloads\mytest\console\bin\Debug\net9.0\console.dll

@JanKrivanek
Copy link
Member Author

Thanks @YuliiaKovalova for helping to improve the Downloads location obtaining logic!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate an error or warning when building under the downloads folder
3 participants