-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
I am trying to run a benchmark against a library which uses a custom code generator for schema files. I am specifically trying to benchmark the generated schema itself so its inclusion is necessary. My project file is quite simple and include a reference to .props and .targets files which are used by the code generator. However, when I try to run benchmarks on this assembly, it fails to build because the autogenerated BenchmarkDotNet.Autogenerated.csproj has invalid syntax. Specifically, the generated project has these lines:
<Optimize Condition=" '$(Configuration)' != 'Debug' ">true</Optimize>
<!-- Begin copied settings from benchmarks project -->
LangVersion="$(LangVersion)"
<!-- End copied settings -->
<LangVersion Condition="'$(LangVersion)' == '' Or ($([System.Char]::IsDigit('$(LangVersion)', 0)) And '$(LangVersion)' < '7.3')">latest</LangVersion>
The compile is failing because of the invalid syntax LangVersion="$(LangVersion)" which was presumably copied from my project and targets files. My project file and a portion of the offending .targets file is below.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<Import Project="Parallax.props" />
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.4" />
<PackageReference Include="Parallax" Version="2022.11.04" />
</ItemGroup>
<ItemGroup>
<ParallaxInterface Include="IConfig.plx" />
</ItemGroup>
<Import Project="Parallax.CodeGenerator.targets" />
</Project>
Inside Parallax.CodeGenerator.targets is the offending code, under the <Csc> target.
If I remove the line LangVersion="$(LangVersion)", the benchmark build works perfectly fine.
<!-- Compile separate implementation assembly -->
<Target Name="CompileImplementationAssembly"
AfterTargets="CoreCompile"
BeforeTargets="BinplaceFiles"
DependsOnTargets="CopyParallaxBinaries;GetParallaxReferencePath"
Condition="@(ParallaxInterface) != '' AND '$(ParallaxDisableSeparateAssembly)' == '' AND '$(EnableBinaryParallax)' == ''"
Inputs="@(ParallaxInterface); @(ParallaxReferencePath); $(MSBuildAllProjects)"
Outputs="$(_parallaxGeneratedAssembly)">
<!-- Create parameters file -->
<WriteLinesToFile File="$(_parametersFile)" Lines="--csharpImplementation" Overwrite="true"/>
<WriteLinesToFile File="$(_parametersFile)" Lines="$(_implementationLog)" Overwrite="false"/>
<WriteLinesToFile File="$(_parametersFile)" Lines="--schemaFiles" Overwrite="false"/>
<WriteLinesToFile File="$(_parametersFile)" Lines="@(ParallaxInterface -> '%(FullPath)')" Overwrite="false"/>
<WriteLinesToFile File="$(_parametersFile)" Lines="--referencedFiles" Overwrite="false"/>
<WriteLinesToFile File="$(_parametersFile)" Lines="@(CustomReferencePaths -> '%(FullPath)')" Overwrite="false" Condition="'$(UseCustomReferences)' == 'true'" />
<WriteLinesToFile File="$(_parametersFile)" Lines="@(ParallaxReferencePath -> '%(FullPath)')" Overwrite="false" Condition="'$(UseCustomReferences)' != 'true'" />
<WriteLinesToFile File="$(_parametersFile)" Lines="--interfaceNamePrefix" Condition="$(ParallaxInterfaceNamePrefix) != ''" Overwrite="false"/>
<WriteLinesToFile File="$(_parametersFile)" Lines="$(ParallaxInterfaceNamePrefix)" Condition="$(ParallaxInterfaceNamePrefix) != ''" Overwrite="false"/>
<WriteLinesToFile File="$(_parametersFile)" Lines="--useFileNameProvider" Overwrite="false" Condition="'$(ParallaxUseFileNameProvider)' == 'true'" />
<!-- call CodeGenerator -->
<Exec Command="$(_codeGenerator) --parametersFile "$(_parametersFile)""
WorkingDirectory="$(ParallaxGenerationFolder)"
IgnoreStandardErrorWarningFormat="false"/>
<ReadLinesFromFile File="$(_implementationLog)">
<Output TaskParameter="Lines" ItemName="ParallaxCompile"/>
</ReadLinesFromFile>
<Csc Condition="@(ParallaxCompile) != ''"
CodePage="$(CodePage)"
DebugType="$(DebugType)"
DefineConstants="$(DefineConstants)"
DelaySign="$(DelaySign)"
PublicSign="$(PublicSign)"
DisabledWarnings="$(NoWarn)"
EmitDebugInformation="$(DebugSymbols)"
ErrorReport="$(ErrorReport)"
FileAlignment="$(FileAlignment)"
GenerateFullPaths="$(GenerateFullPaths)"
KeyContainer="$(KeyContainerName)"
KeyFile="$(KeyOriginatorFile)"
LangVersion="$(LangVersion)"
NoConfig="true"
NoStandardLib="$(NoCompilerStandardLib)"
NoWin32Manifest="$(NoWin32Manifest)"
Optimize="$(Optimize)"
OutputAssembly="$(_parallaxGeneratedAssembly)"
PdbFile="$(PdbFile)"
Platform="$(PlatformTarget)"
References="@(ParallaxReferencePath)"
Sources="@(ParallaxCompile)"
TargetType="library"
ToolExe="$(CscToolExe)"
ToolPath="$(CscToolPath)"
AllowUnsafeBlocks="true"
/>
<Message Condition="@(ParallaxCompile) != ''" Text="Compiled parallax assembly: $(_parallaxGeneratedAssembly)" Importance="high" />
<Copy SourceFiles="$(_parallaxGeneratedAssembly)" DestinationFolder="$(OutputPath)" Condition="@(ParallaxCompile) != ''" SkipUnchangedFiles="true"/>
<ItemGroup>
<Binplace Include="$(_parallaxGeneratedAssembly)" Condition="@(ParallaxCompile) != ''">
<DestinationFolder>$(BinplaceLocalLibPath)</DestinationFolder>
</Binplace>
</ItemGroup>
</Target>