Skip to content

Fix crash when using AdditionalManifestFiles on 32-bit Windows targets #416

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

usernameak
Copy link

Fixes a crash that appears when you add additional manifest files while targeting 32-bit Windows. The crash is caused by EnvironmentVariableResolver for that platform being null.

[ERROR]                                              
Error:                                               
Object reference not set to an instance of an object.
        While running D:\src\Sharpmake\Sharpmake.Application\bin\Debug\net6.0\Sharpmake.Application.exe
        @06/20/2025 04:16:31: Exception message (level 0):
        Error encountered while generating HelloWorld.HelloWorldProject
        Inner exception message (level 1):
        Object reference not set to an instance of an object.

        Stack trace:
        Inner exception stack trace (level 1):
   at Sharpmake.Generators.FastBuild.Bff.CmdLineConvertIncludePathsFunc(IGenerationContext context, Resolver resolver, String include, String prefix) in D:\src\Sharpmake\Sharpmake.Generators\FastBuild\Bff.cs:line 1558
   at Sharpmake.Generators.VisualStudio.ProjectOptionsGenerator.<>c__DisplayClass18_0.<GenerateManifestToolOptions>b__4(String p) in D:\src\Sharpmake\Sharpmake.Generators\VisualStudio\ProjectOptionsGenerator.cs:line 1912
   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
   at System.String.Join(String separator, IEnumerable`1 values)
   at Sharpmake.Generators.VisualStudio.ProjectOptionsGenerator.GenerateManifestToolOptions(IGenerationContext context, ProjectOptionsGenerationContext optionsContext) in D:\src\Sharpmake\Sharpmake.Generators\VisualStudio\ProjectOptionsGenerator
.cs:line 1914
   at Sharpmake.Generators.VisualStudio.ProjectOptionsGenerator.GenerateOptions(IGenerationContext context, ProjectOptionGenerationLevel level) in D:\src\Sharpmake\Sharpmake.Generators\VisualStudio\ProjectOptionsGenerator.cs:line 97
   at Sharpmake.Generators.VisualStudio.Vcxproj.GenerateConfOptions(GenerationContext context) in D:\src\Sharpmake\Sharpmake.Generators\VisualStudio\Vcxproj.cs:line 350
   at Sharpmake.Generators.VisualStudio.Vcxproj.GenerateImpl(GenerationContext context, IList`1 generatedFiles, IList`1 skipFiles) in D:\src\Sharpmake\Sharpmake.Generators\VisualStudio\Vcxproj.cs:line 363
   at Sharpmake.Generators.VisualStudio.Vcxproj.Generate(Builder builder, Project project, List`1 configurations, String projectFile, List`1 generatedFiles, List`1 skipFiles) in D:\src\Sharpmake\Sharpmake.Generators\VisualStudio\Vcxproj.cs:line 
144
   at Sharpmake.Generators.GeneratorManager.Generate(Builder builder, Project project, List`1 configurations, String projectFile, List`1 generatedFiles, List`1 skipFiles) in D:\src\Sharpmake\Sharpmake.Generators\GeneratorManager.cs:line 103     
   at Sharpmake.Builder.GenerateProjectFile(Object arg) in D:\src\Sharpmake\Sharpmake\Builder.cs:line 1302
        Root stack trace (level 0):
   at Sharpmake.Application.Program.CreateBuilderAndGenerate(BaseBuildContext buildContext, Argument parameters, Boolean generateDebugSolution) in D:\src\Sharpmake\Sharpmake.Application\Program.cs:line 481
   at Sharpmake.Application.Program.GenerateAll(BaseBuildContext buildContext, Argument parameters) in D:\src\Sharpmake\Sharpmake.Application\Program.cs:line 520
   at Sharpmake.Application.Program.Main() in D:\src\Sharpmake\Sharpmake.Application\Program.cs:line 307

1 errors, 0 warnings

To reproduce, use this (assuming [project.SourceRootPath]\app.manifest points to a valid manifest file location) and try generating targeting Win32 (not Win64) platform:

conf.Options.Add(Options.CSharp.GenerateManifests.Enabled);
conf.AdditionalManifestFiles.Add(@"[project.SourceRootPath]\app.manifest");

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.

1 participant