Skip to content

MsBuildProjectContextBuilder drops MSBuild output on the floor  #1738

Open
@yecril71pl

Description

@yecril71pl

File a bug

Build intercepts the output of MSBuild and drops it on the floor.

Include your code

        public IProjectContext Build()
        {
            var errors = new List<string>();
            var output = new List<string>();
            var tmpFile = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            var result = 
             Command.CreateDotNet(
                "msbuild",
                new string[]
                {
                    _projectPath,
                    $"/t:EvaluateProjectInfoForCodeGeneration",
                    $"/p:OutputFile={tmpFile};CodeGenerationTargetLocation={_targetLocation};Configuration={_configuration}"
                })
                .OnErrorLine(e => errors.Add(e))
                .OnOutputLine(o => output.Add(o))
                .Execute();

            if (result.ExitCode != 0)
            {
                throw CreateProjectContextCreationFailedException(_projectPath, errors);
            }
            try
            {
                var info = File.ReadAllText(tmpFile);

                var buildContext = JsonConvert.DeserializeObject<CommonProjectContext>(info);

                return buildContext;
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("Failed to read the BuildContext information.", ex);
            }
        }

Include stack traces

 at Microsoft.Extensions.ProjectModel.MsBuildProjectContextBuilder.Build() in /tmp/Scaffolding/src/Shared/Microsoft.DotNet.Scaffolding.Shared/MsBuild/MsBuildProjectContextBuilder.cs:line 58
 at Microsoft.VisualStudio.Web.CodeGeneration.Tools.Program.GetProjectInformation(String projectPath, String configuration) in /tmp/Scaffolding/tools/dotnet-aspnet-codegenerator/Program.cs:line 298

Include provider and version information

Microsoft.VisualStudio.Web.CodeGeneration.Design/Microsoft.DotNet.MSIdentity version:
1.0.0
Target framework: (e.g. .NET 5.0)
net6.0
Operating system:
Linux x64 5.15.6-1-default
IDE: (e.g. Visual Studio 2019 16.3)
1.63.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions