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

MsBuildProjectContextBuilder drops MSBuild output on the floor #1738

Open
yecril71pl opened this issue Dec 14, 2021 · 0 comments · May be fixed by #1739
Open

MsBuildProjectContextBuilder drops MSBuild output on the floor #1738

yecril71pl opened this issue Dec 14, 2021 · 0 comments · May be fixed by #1739

Comments

@yecril71pl
Copy link
Contributor

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
yecril71pl added a commit to yecril71pl/Scaffolding that referenced this issue Dec 14, 2021
Do not intercept output from MSBuild
Fixes dotnet#1738
@yecril71pl yecril71pl linked a pull request Dec 14, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant