AaronRobinsonMSFT / DNNE

Prototype native exports for a .NET Assembly.
MIT License
404 stars 41 forks source link

Task DnneGenerateNativeExports should fail gracefully, and/or provide warnings or errors when no exports are defined #144

Closed Tyler-IN closed 1 year ago

Tyler-IN commented 1 year ago
  <Target
    Name="DnneGenerateNativeExports"
    Condition="('$(DesignTimeBuild)' != 'true' OR '$(BuildingProject)' == 'true') AND '$(DnneBuildExports)' == 'true'"
    Inputs="@(IntermediateAssembly)"
    Outputs="@(DnneGeneratedSourceFile)"
    AfterTargets="CoreCompile">
    <Message Text="Generating source for @(IntermediateAssembly) into @(DnneGeneratedSourceFile)" Importance="$(DnneMSBuildLogging)" />

    <!-- Ensure the output directory exists -->
    <MakeDir Directories="$(DnneGeneratedOutputPath)" />

    <PropertyGroup>
      <DocFlag Condition="Exists($(DocumentationFile))">-d &quot;$(DocumentationFile)&quot;</DocFlag>
    </PropertyGroup>

    <Exec Command="$(DnneGenExe) @(IntermediateAssembly) $(DocFlag) -o @(DnneGeneratedSourceFile)" />
  </Target>

The Exec task fails and the output stating why it failed requires careful scrutiny of logs.

The build will fail because the output C file (dnne/*.g.c) will be absent.

c1 : fatal error C1083: Cannot open source file: X:\...\obj\...\dnne\ProjectName.g.c

Either it needs to 'allow' the file to be absent, and/or issue warnings or errors instead of simply stating the file is missing.

There are CustomErrorRegularExpression and CustomWarningRegularExpression which can be applied according to the Exec task docs. Verifying the existence of the output file could also be a good follow up.