MsBuildProjectContextBuilder drops MSBuild output on the floor
- Dominant language
- C#
- Stars
- 818
- Forks
- 260
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 10
Description
## File a bug
`Build` intercepts the output of `MSBuild` and drops it on the floor.
### Include your code
```C#
public IProjectContext Build()
{
var errors = new List();
var output = new List();
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(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
Contributor guide
Assessment
This issue has not been assessed yet.