GithubHelp home page GithubHelp logo

Comments (10)

sarajoiner avatar sarajoiner commented on July 17, 2024

Item creation from the output of a task should append to an item list in the same way a normal Include would. If that's not happening, I would say that that is the real issue here.

from msbuild.

olivierdagenais avatar olivierdagenais commented on July 17, 2024

OK, I'll try to reproduce that specific scenario.

from msbuild.

olivierdagenais avatar olivierdagenais commented on July 17, 2024

Item creation from the output of a task should append to an item list in the same way a normal Include would.

Confirmed with this MSBuild script:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build"
         xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <UsingTask TaskName="Generator" TaskFactory="CodeTaskFactory"
             AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
    <ParameterGroup>
      <StartPoint ParameterType="System.Int32" Required="true" />
      <Generated ParameterType="Microsoft.Build.Framework.ITaskItem[]" Output="true" />
    </ParameterGroup>
    <Task>
      <Code Type="Fragment" Language="cs"><![CDATA[
const int Max = 10;
Generated = new TaskItem[Max];
for (int c = 0, d = StartPoint; c < Max; c++, d++)
{
  Generated[c] = new TaskItem(Convert.ToString(d, 10));
}]]></Code>
    </Task>
  </UsingTask>
  <Target Name="Build">
    <Generator StartPoint="0">
      <Output TaskParameter="Generated" ItemName="g" />
    </Generator>
    <Message Importance="high" Text="g: @(g)" />

    <Generator StartPoint="20">
      <Output TaskParameter="Generated" ItemName="g" />
    </Generator>
    <Message Importance="high" Text="g: @(g)" />
  </Target>

</Project>

...I'll next chase down why the append isn't happening in this particular case.

from msbuild.

olivierdagenais avatar olivierdagenais commented on July 17, 2024

Whoa, I don't understand how I got it so wrong the first time around and after reviewing the .metaproj files it seems so obvious now. I was close, though: the [generated] .csproj.metaproj file's <Target> elements are missing an Outputs attribute to relay back the contents of (in this case) MSBuildIssueBuildOutput:

<Target Name="Build" Outputs="@(MSBuildIssueBuildOutput)">
  <MSBuild Projects="@(ProjectReference)" BuildInParallel="True" Properties="BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" SkipNonexistentProjects="%(ProjectReference.SkipNonexistentProjects)">
    <Output TaskParameter="TargetOutputs" ItemName="MSBuildIssueBuildOutput" />
  </MSBuild>
  <MSBuild Projects="C:\Users\odagenais\oss\MSBuildIssue\Repro\MSBuildIssue\MSBuildIssue.csproj" BuildInParallel="True" ToolsVersion="$(ProjectToolsVersion)" Properties="Configuration=Debug; Platform=AnyCPU;BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)">
    <Output TaskParameter="TargetOutputs" ItemName="MSBuildIssueBuildOutput" />
  </MSBuild>
</Target>

...which explains how the repro files would only talk about the other (non-transformed) project; its outputs were indeed properly collected (and were the only ones shown) and it wasn't a corruption of the output of the .csproj.metaproj files we were seeing, but rather the absence of output.

For my next trick, I'll encode my findings into a failing unit test and then we can discuss how to fix this.

from msbuild.

olivierdagenais avatar olivierdagenais commented on July 17, 2024

You can cherry-pick the [failing] unit test as b5f7056 in the 69-metaprojects_should_relay_outputs branch of my fork.

from msbuild.

olivierdagenais avatar olivierdagenais commented on July 17, 2024

I'm developing on Windows 7 with Visual Studio 2013, so I understand there are some tests that are known to fail (as per issue #30) and, according to the README, a sub-optimal experience without VS 2015, but my proposed fix in 0af88d9 indeed fixes the broken test I introduced and does not appear to break other tests.

Let me know what you think and I can open a pull request after reviewing other possible instances of this sort of "missing relay".

BTW, the unit test I added creates some files in %LocalAppData%\Temp\TempDirForMSBuildUnitTests, which allows one to also reproduce the defect with older versions of MSBuild (as had been initially reported in the Connect report) by running something like:

"c:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" automatic.msbuild /verbosity:minimal

from msbuild.

olivierdagenais avatar olivierdagenais commented on July 17, 2024

What do you think, @sarajoiner?

from msbuild.

sarajoiner avatar sarajoiner commented on July 17, 2024

Added a couple of comments. Definitely looks like you're on the right track to me. :)

from msbuild.

olivierdagenais avatar olivierdagenais commented on July 17, 2024

Added a couple of comments. Definitely looks like you're on the right track to me. :)

Fabulous! Does this mean I satisfy the first two "limits" outlined in Contributing Code?

  • Contributions must be discussed with the team first, or they will likely be declined.
  • Only contributions referencing an approved Issue will be accepted.

In other words, does your last comment imply the contribution has been discussed (my pull request will of course address your comments and be more thorough) and that this issue is approved?

from msbuild.

sarajoiner avatar sarajoiner commented on July 17, 2024

Ah ... Unfortunately, I'm not a current member of the MSBuild team. So my opinion may hold some weight, but I don't think it counts as an official "go ahead".

@AndyGerlicher, @ValMenn, @dannyvv, @NikolaiTillmann, would one of you care to weigh in?

from msbuild.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.