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

Create empty Directory.Build.props to ignore other prop files #2467

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

Conversation

adamsitnik
Copy link
Member

@adamsitnik adamsitnik commented Nov 16, 2023

Context: #2371 (comment)

It should not affect the WASM benchmarks (cc @radical), as they have their own generator:

string content = new StringBuilder(ResourceHelper.LoadTemplate("WasmCsProj.txt"))

<OriginalCSProjPath>$CSPROJPATH$</OriginalCSProjPath>
<WasmPropsPath>$([System.IO.Path]::ChangeExtension('$(OriginalCSProjPath)', '.Wasm.props'))</WasmPropsPath>
<WasmTargetsPath>$([System.IO.Path]::ChangeExtension('$(OriginalCSProjPath)', '.Wasm.targets'))</WasmTargetsPath>

which links a dedicated props file: https://github.com/dotnet/performance/blob/main/src/benchmarks/micro/MicroBenchmarks.Wasm.props

But I am not sure about dotnet/performance in general, as IIRC the props file there alters some settings like build output path. This is going to require a detailed testing (@cincuranet @LoopedBard3 @DrewScoggins @caaavik-msft @sblom)

fixes #2371

@adamsitnik adamsitnik added this to the v0.13.11 milestone Nov 16, 2023
@adamsitnik adamsitnik self-assigned this Nov 16, 2023
@timcassell
Copy link
Collaborator

timcassell commented Dec 4, 2023

Perhaps we could adjust the csproj to make it work, instead of adding a Directory.Build.props?

Old:

<Project Sdk="$SDKNAME$">
  <PropertyGroup>
    <ImportDirectoryBuildProps>false</ImportDirectoryBuildProps>
    <ImportDirectoryBuildTargets>false</ImportDirectoryBuildTargets>
  </PropertyGroup>
</Project>

New:

<Project>
  <PropertyGroup>
    <ImportDirectoryBuildProps>false</ImportDirectoryBuildProps>
    <ImportDirectoryBuildTargets>false</ImportDirectoryBuildTargets>
  </PropertyGroup>
  
  <Sdk Name="$SDKNAME$">
</Project>

(I forgot where I read that that could work.)

[Edit] Sources:
dotnet/msbuild#1680 (comment)
https://stackoverflow.com/a/57902835

So, I'm not entirely sure it will work with <Sdk> element (I think it should), it might need to be something like this:

<Project>
  <PropertyGroup>
    <ImportDirectoryBuildProps>false</ImportDirectoryBuildProps>
    <ImportDirectoryBuildTargets>false</ImportDirectoryBuildTargets>
  </PropertyGroup>
  
  <Import Project="Sdk.props" Sdk="$SDKNAME$" />
  <Import Project="Sdk.targets" Sdk="$SDKNAME$" />
</Project>

@adamsitnik
Copy link
Member Author

I'm not entirely sure it will work

The solution that I am proposing here was recommended in #2371 (comment) by @ViktorHofer who is the MSBuild expert on the .NET Team. It just works.

@ViktorHofer
Copy link
Member

Yeah, you could defer the SDK import but that would make the project file look very different. The Directory.Build.props solution is my preferred approach.

@AndreyAkinshin AndreyAkinshin removed this from the v0.13.11 milestone Dec 6, 2023
@timcassell
Copy link
Collaborator

timcassell commented Feb 8, 2024

But I am not sure about dotnet/performance in general, as IIRC the props file there alters some settings like build output path.

That was addressed in #2393. The cli arguments override whatever is in the props, even if we don't ignore it. I'm not sure if other properties are consequential, but this looks good to me otherwise. Should we expose an API for whether or not to ignore props files? [Edit] Actually that could be overridden with a MsBuildArgument, no need for a new API.

@timcassell
Copy link
Collaborator

It should not affect the WASM benchmarks (cc @radical), as they have their own generator:
...
which links a dedicated props file: https://github.com/dotnet/performance/blob/main/src/benchmarks/micro/MicroBenchmarks.Wasm.props

The directory props are imported before the project, so there it would be importing 2 props files, no? Wouldn't we want to ignore the directory props in the case of wasm also?

Also, the NativeAot generator needs this as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generated benchmarks ignore --framework flag when running out of process
4 participants