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

Build can fail in WPF projects #89

Open
johannesegger opened this issue Sep 9, 2016 · 1 comment
Open

Build can fail in WPF projects #89

johannesegger opened this issue Sep 9, 2016 · 1 comment
Labels

Comments

@johannesegger
Copy link

johannesegger commented Sep 9, 2016

When used inside WPF projects the MSBuild task GenerateCodeFromAttributes might fail:

The "GenerateCodeFromAttributes" task failed unexpectedly. [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
System.IO.FileNotFoundException: Could not find file 'C:\Users\egger\Workspace\MSBuildTest\LibA\bin\Debug\LibA.dll'. [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
File name: 'C:\Users\egger\Workspace\MSBuildTest\LibA\bin\Debug\LibA.dll' [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at System.IO.File.OpenRead(String path) [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at Roslyn.Utilities.FileUtilities.OpenFileStream(String path) [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String path, MetadataReferenceProperties properties, DocumentationProvider documentation) [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at CodeGeneration.Roslyn.Tasks.GenerateCodeFromAttributes.Helper.<>c.<CreateProject>b__40_0(ITaskItem p) [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext() [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source) [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items) [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at Roslyn.Utilities.ImmutableArrayExtensions.ToImmutableArrayOrEmpty[T](IEnumerable`1 items) [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at Roslyn.Utilities.ImmutableArrayExtensions.ToImmutableReadOnlyListOrEmpty[T](IEnumerable`1 items) [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at Microsoft.CodeAnalysis.ProjectInfo.WithMetadataReferences(IEnumerable`1 metadataReferences) [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at Microsoft.CodeAnalysis.ProjectState.WithMetadataReferences(IEnumerable`1 metadataReferences) [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at Microsoft.CodeAnalysis.Solution.WithProjectMetadataReferences(ProjectId projectId, IEnumerable`1 metadataReferences) [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at Microsoft.CodeAnalysis.Project.WithMetadataReferences(IEnumerable`1 metadataReferences) [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at CodeGeneration.Roslyn.Tasks.GenerateCodeFromAttributes.Helper.CreateProject() [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at CodeGeneration.Roslyn.Tasks.GenerateCodeFromAttributes.Helper.<<Execute>b__36_0>d.MoveNext() [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
--- End of stack trace from previous location where exception was thrown --- [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at CodeGeneration.Roslyn.Tasks.GenerateCodeFromAttributes.Helper.Execute() [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at CodeGeneration.Roslyn.Tasks.GenerateCodeFromAttributes.Helper.Execute() [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at CodeGeneration.Roslyn.Tasks.GenerateCodeFromAttributes.Execute() [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() [C:\Users\egger\Workspace\MSBuildTest\WpfApp\2wvt5w2v.tmp_proj]

This only happens when two-pass-compilation happens (i.e. when XAML files reference types from the same assembly).
The obvious workaround is to separate the XAML stuff from the CodeGen stuff, but do you think you could fix this in your library?

For a sample repo that reproduces this see https://github.com/Weingartner/ImmutableObjectGraphAndWpfFail

@AArnott AArnott added the bug label Sep 11, 2016
@AArnott
Copy link
Owner

AArnott commented Sep 11, 2016

Thanks for the report. Yes, I hope we can fix this.

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

2 participants