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

Return false if there are no sources #9208

Merged
merged 4 commits into from
Sep 27, 2023
Merged

Return false if there are no sources #9208

merged 4 commits into from
Sep 27, 2023

Conversation

JaynieBai
Copy link
Member

@JaynieBai JaynieBai commented Sep 7, 2023

Fixes #9199

Context

The unhandled exception is from https://github.com/dotnet/msbuild/blob/3c910ba83fc9dbd8e12f50dddc8c381404f928c4/src/Tasks/GenerateResource.cs#L1132C13-L1133. But when source is not found and has errors, it should return false in Execute function.

Changes Made

Return false if there are no valid sources found.

Testing

Add a unit test case.
image

Notes

@JaynieBai JaynieBai changed the title return false if there are sources return false if there are no sources Sep 7, 2023
@JaynieBai JaynieBai changed the title return false if there are no sources Return false if there are no sources Sep 7, 2023
@JaynieBai JaynieBai marked this pull request as ready for review September 11, 2023 06:17
src/Tasks/GenerateResource.cs Outdated Show resolved Hide resolved
Co-authored-by: Rainer Sigwald <raines@microsoft.com>
@rainersigwald rainersigwald merged commit 5778159 into main Sep 27, 2023
8 checks passed
@rainersigwald rainersigwald deleted the jennybai/issue9199 branch September 27, 2023 13:35
bulatgrzegorz pushed a commit to bulatgrzegorz/selective-condition-evaluator that referenced this pull request Oct 16, 2023
…net#9208)

Fixes dotnet#9199 by avoiding an unhandled exception:

```
"C:\temp\testgenres\project.proj" (default target) (1) ->
  MSBUILD : error : This is an unhandled exception in MSBuild -- PLEASE UPVOTE AN EXISTING ISSUE OR FILE A NEW ONE AT https://aka.ms/msbuild/unhandled [C:\temp\testgenres\project.proj]
MSBUILD : error :     Microsoft.Build.Framework.InternalErrorException: MSB0001: Internal MSBuild Error: There should be resource files to process [C:\temp\testgenres\project.proj]
MSBUILD : error :    at Microsoft.Build.Shared.ErrorUtilities.ThrowInternalError(String message, Exception innerException, Object[] args) [C:\temp\testgenres\project.proj]
MSBUILD : error :    at Microsoft.Build.Tasks.GenerateResource.TransformResourceFilesUsingResGen(List`1 inputsToProcess, List`1 outputsToProcess) [C:\temp\testgenres\project.proj]
MSBUILD : error :    at Microsoft.Build.Tasks.GenerateResource.GenerateResourcesUsingResGen(List`1 inputsToProcess, List`1 outputsToProcess) [C:\temp\testgenres\project.proj]
MSBUILD : error :    at Microsoft.Build.Tasks.GenerateResource.Execute() [C:\temp\testgenres\project.proj]
```
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.

[Bug]: GenerateResource crashes when passed a non-existent file
3 participants