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

Solution meta-project doesn't propagate target return values for custom targets #3658

Open
tmat opened this issue Aug 27, 2018 · 6 comments
Open
Labels

Comments

@tmat
Copy link
Member

tmat commented Aug 27, 2018

Steps to reproduce

Project file a.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net46</TargetFramework>
  </PropertyGroup>

  <Target Name="T" Returns="@(Thing)">
    <ItemGroup>
      <Thing Include="A"/>
      <Thing Include="B"/>
      <Thing Include="C"/>
    </ItemGroup>
  </Target>
</Project>

Solution A.sln containing a.csproj.

Project file x.proj

<Project>
  <Target Name="Build">
    <MSBuild Projects="A.sln" Targets="T">
      <Output ItemName="Thing" TaskParameter="TargetOutputs" />
    </MSBuild>

    <Message Text="Things: '@(Thing)'"/>
  </Target>
</Project>

Command line

msbuild x.proj

Expected behavior

Things: 'A;B;C'

Actual behavior

Things: ''

Environment data

msbuild /version output:

Microsoft (R) Build Engine version 15.8.166+gd4e8d81a88 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
@rainersigwald rainersigwald changed the title Solution meta-project doesn't propagate target return values Solution meta-project doesn't propagate target return values for custom targets Aug 27, 2018
@rainersigwald
Copy link
Member

I think that'd be a reasonable enhancement, though I hope it's never needed.

@tmat
Copy link
Member Author

tmat commented Aug 27, 2018

Why should it not be needed? It if was not needed I wouldn't file an issue.

I would like to collect some information from all projects in a given solution. For example, find all test projects and all platforms they target and need to run tests on, so we can schedule test runs more efficiently than if we launch XUnit from within each test project.

@rainersigwald
Copy link
Member

For that use, consider waiting for microsoft/vstest#411, which the test folks are working on.

Calling targets for every project in a solution is error-prone, because solutions can contain non-MSBuild projects and heterogeneous projects that don't all contain the desired target. So building infrastructure that depends on it seems risky to me.

@tmat
Copy link
Member Author

tmat commented Aug 27, 2018

because solutions can contain non-MSBuild projects and heterogeneous projects that don't all contain the desired target

Good point. It would also be useful to have an option for skipping non-existing targets, similarly to the option SkipNonexistentProjects.

@rainersigwald
Copy link
Member

There is SkipNonexistentTargets as of #2541. But it's not clear to me that always specifying it is the right thing to do for msbuild a.sln /t:Custom. For Test you'd want it, but for a hypthetical ValidateProjectDefinesSomeProperty you wouldn't. We don't currently specify it for the generated traversal targets.

@tmat
Copy link
Member Author

tmat commented Aug 27, 2018

@rainersigwald Cool. Yes, it's definitely dependent on the scenario. You can either require all projects in the solution to import targets file with the custom target and then expect it to be everywhere or not if it's optional.

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

No branches or pull requests

3 participants