0

I have created dot net core dll project. CS files for this project will be files generated by tool (Apache Thrift compiler) but output dll is not picking up generated file. I have added the pre build set to generate the file.

Repro Steps:

  1. Build solution

  2. Open the ThriftSample.dll with object brower. (Delete the generated cs files and bin, com and obj folder.)

Actual: Nothing is there in ThriftSample.dll

Expected: Generated CS code should be there.

Note: I have checked CS file is generated. Attached is the sample project.( https://onedrive.live.com/?cid=aef000afffca3540&id=AEF000AFFFCA3540%21144&authkey=!AAlMaW2IqIt6l1k )

Tom
  • 13
  • 4

1 Answers1

-1

Refer: Is there a .NET Core CLI pre before build task?

The "default items" as the .NET SDK calls it are part of the static evaluation of the project file - before any target is run. So you'll need a target that is run before the @(Compile) items are needed.

The trick is to include files added to the filesystem after the custom tool is run. This can be done by re-scanning all files and excluding those already part of the project inside a target that is run before the build:

<Target Name="GenerateSomeFiles" BeforeTargets="BeforeBuild">
<Exec Command="dotnet my-tool" />
    <ItemGroup>
      <Compile Include="**/*$(DefaultLanguageSourceExtension)"
               Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);$(BaseIntermediateOutputPath)**;$(BaseOutputPath)**;@(Compile)" />
    </ItemGroup>
  </Target>
Tom
  • 13
  • 4