Comments (10)
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.
OK, I'll try to reproduce that specific scenario.
from msbuild.
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.
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.
You can cherry-pick the [failing] unit test as b5f7056 in the 69-metaprojects_should_relay_outputs
branch of my fork.
from msbuild.
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.
What do you think, @sarajoiner?
from msbuild.
Added a couple of comments. Definitely looks like you're on the right track to me. :)
from msbuild.
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.
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)
- [Bug]: Cannot use Microsoft.Build.Utilities.Core 17.10.4 NuGet package HOT 4
- Correct way to generate sources for an external project (with incompatible `TargetFramework`)?
- [Feature Request]: Localize MSBuild messages with MSBuildInternalMessage task
- [Bug]: BuildCheck: Internal error thrown when reporting results HOT 1
- [Broken Build]: Blazor Integrity issue HOT 1
- [Bug]: NRE in at Microsoft.Build.BackEnd.TargetEntry.<ExecuteTarget>d__44.MoveNext() HOT 4
- Request to backport getResultOutputFile from 8.0.3xx to 8.0.1xx SDK. HOT 3
- [Bug]: CI/CD pipeline broken after update from 17.9 to 17.10: no Appx packages generated HOT 3
- [Bug]: OOM Exception due to infinite loop in FileMatcher HOT 2
- [Feature Request]: The way publish dll only HOT 7
- [Refactoring] Move all Xml*WithLocation to Microsoft.Build.Framework
- [Feature Request]: Reduce the wrapping around SDK Resolver messages when only one resolver is actually invoked HOT 1
- Analyzer for Property read before assigned HOT 2
- [Bug]: Incorrect framework library is used sometimes during build HOT 1
- Q: Verifying NuGet single multi targeting build assets importation HOT 25
- [Bug]: Project file does not exist with LongPaths HOT 4
- [Bug]: Breaking change in serialized BuildResult can lead to errors in result caching with older data HOT 1
- Add documentation for the risks for version incompatibilities between msbuild and a plugin dependencies HOT 8
- MSBuild Threat Modeling
- MSBuild High Level Overview document
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from msbuild.