dotnet / project-system

The .NET Project System for Visual Studio
MIT License
967 stars 386 forks source link

Normal builds still run under devenv.exe in VS 16.0 Pre2 #4494

Open davkean opened 5 years ago

davkean commented 5 years ago

From @jeromelaban on January 24, 2019 13:23

Steps to reproduce

When build this solution, and more specifically this project under visual studio, the following message appear:

1>------ Build started: Project: Uno.UI (Uno.UI\Uno.UI), Configuration: Debug Any CPU ------
1>Building target framework: xamarinmac20
1>Building target framework: xamarinios10
1>Building target framework: net46
1>Building target framework: netstandard2.0
1>src\SourceGenerators\Uno.UI.Tasks\Content\Uno.UI.Tasks.targets(53,5): warning : The Uno.UI.Tasks build task is running under devenv.exe you will have to restart Visual Studio to rebuild it.
1>Done building project "Uno.UI.csproj".
1>src\SourceGenerators\Uno.UI.Tasks\Content\Uno.UI.Tasks.targets(77,5): warning : The Uno.UI.Tasks build task is running under devenv.exe you will have to restart Visual Studio to rebuild it.
1>Done building project "Uno.UI.csproj".

This message is produced by this task to warn the user of a devenv.exe locked task.

I tried reproducing using a smaller sample, but could not get it.

Environment data

msbuild /version output:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview>msbuild /version
Microsoft (R) Build Engine version 16.0.360-preview+g9781d96883 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

16.0.360.33175

OS info:

Microsoft Windows [Version 10.0.17134.472]
(c) 2018 Microsoft Corporation. All rights reserved.

Copied from original issue: Microsoft/msbuild#4095

davkean commented 5 years ago

I can repro this. We're definitely asking for an OutOfProc build here, so not sure why we're being pulled in proc. Investigating.

davkean commented 5 years ago

Okay, I've got it down to:

    <MSBuild Projects="$(MSBuildProjectFile)"
             Targets="_InnerUnoResourcesGeneration_Assets"
             BuildInParallel="true"
             Properties="Configuration=$(Configuration);Platform=$(Platform);Dummy2=true">
      <Output TaskParameter="TargetOutputs" ItemName="UnoRetargetedAssetsOutput" />
    </MSBuild>

The original build request to build the project was run out-of-proc, but it appears to service the above request with an in-proc node that was running for something else. I would have expected this to respect the NodeAffinity of the original request. Started a thread with MSBuild folks.

davkean commented 5 years ago

@jeromelaban What's the reason you are adding the dummy global property?

jeromelaban commented 5 years ago

@davkean It's was a guess about trying to really spawn another msbuild nodes based on the documentation that says:

When you pass properties to the project through the Properties parameter, MSBuild creates a new instance of the project even if the project file has already been loaded.

But it did not seem to change much, and I did not remove it. That being said, in the latest master of Uno, I've removed the sub-msbuilds (it caused me others issues, and did not fix this issue), and the top level msbuild is still running in devenv.exe: https://github.com/nventive/Uno/blob/ab1e38a5c0d681247875f0995df85228d0459717/src/SourceGenerators/Uno.UI.Tasks/Content/Uno.UI.Tasks.targets#L31

davkean commented 5 years ago

Are you saying its unrelated to the MSBuild call above?

jeromelaban commented 5 years ago

It looks like it yes, but it devenv.exe is selected more often if the MSBuild above is defined.

davkean commented 5 years ago

@jeromelaban Just want to make sure you are verifying this using the "warning appearing in the Output window" and not another mechanism to rule out known/expected in-proc usage.

jeromelaban commented 5 years ago

@davkean Just using this task at this location, nothing else fancy.

davkean commented 4 years ago

@jeromelaban Sorry for the lack of followup on this. I believe this is fixed, I cannot repro in current builds but that branch I sync'd to is pretty old and there's other errors - so can't get the exact repro anymore. The root cause of this was due to us (incorrectly) pulling the build in-proc when we encountered certain code generators, and was fixed in the 16.3 timeframe.

jeromelaban commented 4 years ago

Thanks for the update !

Unfortunately, this still happens, when building the Uno solution:

7>C:\s\nv.github\uno\src\SourceGenerators\Uno.UI.Tasks\Content\Uno.UI.Tasks.targets(26,5): warning : The Uno.UI.Tasks build task is running under devenv.exe you will have to restart Visual Studio to rebuild it.

with the same check, using Version 16.4.0 Preview 4.0.

jeromelaban commented 4 years ago

Should I reopen this issue or create a new one ?

davkean commented 4 years ago

@jeromelaban Can you give me a branch that builds without errors other than that? And create a VSConfig with the installed features?

jeromelaban commented 4 years ago

This branch: https://github.com/unoplatform/uno/commit/06ddf8f02e604ace3a03b32b95ac1e4392b388d9

It has .vsconfig setup. It generally seems to happen more with the Xamarin.Android filtered solution.

To build:

Let me know if there's anything else I can help with.

davidwengier commented 4 years ago

I'm trying to repro this locally and I'm getting build errors about from the source generator. Is there anything else I need installed that isn't in the .vsconfig? I got a yellow bar complaining about nodejs so I installed that too, just in case, but I'm also getting the Droid sample app project as being unsupported, despite having the Xamarin workload installed.

10>C:\Users\dawengie\.nuget\packages\uno.sourcegenerationtasks\1.32.0\build\netstandard1.0\Uno.SourceGenerationTasks.targets(127,2): error : Error reading response
10>MSBUILD : error : Generation failed: System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: Generation failed for Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator. System.Exception: Processing failed for file themes\Generic.xaml ---> System.InvalidOperationException: The type mapsPresenter:MapPresenter could not be found
10>MSBUILD : error :    at Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.GetType(String name)
10>MSBUILD : error :    at Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.BuildImplicitStaticResources(IIndentedStringBuilder writer, IEnumerable`1 resources)
10>MSBUILD : error :    at Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.BuildStaticResources(IIndentedStringBuilder writer, Dictionary`2 resources, Dictionary`2 themeResources)
10>MSBUILD : error :    at Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.BuildResourceDictionary(IIndentedStringBuilder writer, XamlObjectDefinition topLevelControl)
10>MSBUILD : error :    at Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.InnerGenerateFile()
10>MSBUILD : error :    at Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.GenerateFile()
10>MSBUILD : error :    --- End of inner exception stack trace ---
10>MSBUILD : error :    at Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.GenerateFile()
10>MSBUILD : error :    at Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGeneration.<>c__DisplayClass23_0.<Generate>b__0(XamlFileDefinition file)
10>MSBUILD : error :    at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
10>MSBUILD : error :    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
10>MSBUILD : error :    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
10>MSBUILD : error :    at Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGeneration.Generate()
10>MSBUILD : error :    at Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator.Execute(SourceGeneratorContext context)
10>MSBUILD : error :    at Uno.SourceGeneration.Host.SourceGeneratorEngine.<>c__DisplayClass4_1.<Generate>b__13(ValueTuple`2 generatorDef)
10>MSBUILD : error :    at Uno.SourceGeneration.Host.SourceGeneratorEngine.<>c__DisplayClass4_1.<Generate>b__13(ValueTuple`2 generatorDef)
10>MSBUILD : error :    at System.Linq.Parallel.SelectQueryOperator`2.SelectQueryOperatorEnumerator`1.MoveNext(TOutput& currentElement, TKey& currentKey)
10>MSBUILD : error :    at System.Linq.Parallel.StopAndGoSpoolingTask`2.SpoolingWork()
10>MSBUILD : error :    at System.Linq.Parallel.SpoolingTaskBase.Work()
10>MSBUILD : error :    at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
10>MSBUILD : error :    at System.Threading.Tasks.Task.Execute()
10>MSBUILD : error :    --- End of inner exception stack trace ---
10>MSBUILD : error : 
10>MSBUILD : error : Server stack trace: 
10>MSBUILD : error :    at System.Linq.Parallel.QueryTaskGroupState.QueryEnd(Boolean userInitiatedDispose)
10>MSBUILD : error :    at System.Linq.Parallel.DefaultMergeHelper`2.System.Linq.Parallel.IMergeHelper<TInputOutput>.Execute()
10>MSBUILD : error :    at System.Linq.Parallel.MergeExecutor`1.Execute[TKey](PartitionedStream`2 partitions, Boolean ignoreOutput, ParallelMergeOptions options, TaskScheduler taskScheduler, Boolean isOrdered, CancellationState cancellationState, Int32 queryId)
10>MSBUILD : error :    at System.Linq.Parallel.PartitionedStreamMerger`1.Receive[TKey](PartitionedStream`2 partitionedStream)
10>MSBUILD : error :    at System.Linq.Parallel.UnaryQueryOperator`2.UnaryQueryOperatorResults.ChildResultsRecipient.Receive[TKey](PartitionedStream`2 inputStream)
10>MSBUILD : error :    at System.Linq.Parallel.ScanQueryOperator`1.ScanEnumerableQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient`1 recipient)
10>MSBUILD : error :    at System.Linq.Parallel.UnaryQueryOperator`2.UnaryQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient`1 recipient)
10>MSBUILD : error :    at System.Linq.Parallel.QueryOperator`1.ExecuteAndGetResultsAsArray()
10>MSBUILD : error :    at Uno.SourceGeneration.Host.SourceGeneratorEngine.Generate()
10>MSBUILD : error :    at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
10>MSBUILD : error :    at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
10>MSBUILD : error : 
10>MSBUILD : error : Exception rethrown at [0]: 
10>MSBUILD : error :    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
10>MSBUILD : error :    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
10>MSBUILD : error :    at Uno.SourceGeneratorTasks.RemoteSourceGeneratorEngine.Generate(RemotableLogger2 logger, BuildEnvironment environment)
10>MSBUILD : error :    at Uno.SourceGeneration.Host.Server.GenerationServerHost.GenerateForCollection(EnvironmentPool collection, BuildEnvironment environment)
10>MSBUILD : error :    at Uno.SourceGeneration.Host.Server.GenerationServerHost.RunGeneration(RunRequest request, CancellationToken cancellationToken)
10>MSBUILD : error : ---> (Inner Exception #0) System.InvalidOperationException: Generation failed for Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator. System.Exception: Processing failed for file themes\Generic.xaml ---> System.InvalidOperationException: The type mapsPresenter:MapPresenter could not be found
10>MSBUILD : error :    at Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.GetType(String name)
10>MSBUILD : error :    at Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.BuildImplicitStaticResources(IIndentedStringBuilder writer, IEnumerable`1 resources)
10>MSBUILD : error :    at Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.BuildStaticResources(IIndentedStringBuilder writer, Dictionary`2 resources, Dictionary`2 themeResources)
10>MSBUILD : error :    at Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.BuildResourceDictionary(IIndentedStringBuilder writer, XamlObjectDefinition topLevelControl)
10>MSBUILD : error :    at Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.InnerGenerateFile()
10>MSBUILD : error :    at Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.GenerateFile()
10>MSBUILD : error :    --- End of inner exception stack trace ---
10>MSBUILD : error :    at Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.GenerateFile()
10>MSBUILD : error :    at Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGeneration.<>c__DisplayClass23_0.<Generate>b__0(XamlFileDefinition file)
10>MSBUILD : error :    at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
10>MSBUILD : error :    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
10>MSBUILD : error :    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
10>MSBUILD : error :    at Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGeneration.Generate()
10>MSBUILD : error :    at Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator.Execute(SourceGeneratorContext context)
10>MSBUILD : error :    at Uno.SourceGeneration.Host.SourceGeneratorEngine.<>c__DisplayClass4_1.<Generate>b__13(ValueTuple`2 generatorDef)
10>MSBUILD : error :    at Uno.SourceGeneration.Host.SourceGeneratorEngine.<>c__DisplayClass4_1.<Generate>b__13(ValueTuple`2 generatorDef)
10>MSBUILD : error :    at System.Linq.Parallel.SelectQueryOperator`2.SelectQueryOperatorEnumerator`1.MoveNext(TOutput& currentElement, TKey& currentKey)
10>MSBUILD : error :    at System.Linq.Parallel.StopAndGoSpoolingTask`2.SpoolingWork()
10>MSBUILD : error :    at System.Linq.Parallel.SpoolingTaskBase.Work()
10>MSBUILD : error :    at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
10>MSBUILD : error :    at System.Threading.Tasks.Task.Execute()<---
10>MSBUILD : error :
10>C:\Users\dawengie\.nuget\packages\uno.sourcegenerationtasks\1.32.0\build\netstandard1.0\Uno.SourceGenerationTasks.targets(127,2): error : Generation failed, error code Rejected
10>Done building project "Uno.UI.Maps.csproj" -- FAILED.
jeromelaban commented 4 years ago

The root of the issue is most likely the fact that Xamarin.Android is considered not installed. NodeJS you can ignore.

Are you able to create and build a standard Xamarin.Android project? (The MapPresenter missing most probably the last error of a very long list of build issues).

Until the project called Uno.UI.BindingHelper.Android builds, the rest of the solution won't build.

davidwengier commented 4 years ago

A normal Xamarin.Android project builds fine, and indeed Uno.UI.BindingHelper.Android builds fine too. The only build errors are that one, and a couple complaining about missing or duplicate resources in the SamplesApp.Droid project.

jeromelaban commented 4 years ago

Duplicate resources are a Xamarin issue, which is not happening all the time.

Adding

<AndroidUseManagedDesignTimeResourceGenerator>False</AndroidUseManagedDesignTimeResourceGenerator>

is likely to help.