Skip to content

MSBuild task should work on virtual projects #12058

@jjonescz

Description

@jjonescz

Summary

Using MSBuild APIs to build in-memory projects should work when targets (e.g., from .NET SDK) include <MSBuild Projects="$(MSBuildProjectFullPath)" /> (which they very often do). Currently MSBuild fails because the project file does not exist on disk. But MSBuild knows its content.

Background and Motivation

File-based apps use MSBuild APIs to build the app in memory (without a physical .csproj file). We need workarounds whenever targets use the MSBuild task against the current project, e.g., NuGet/Home#14148.

Proposed Feature

When using MSBuild APIs like

var xmlReader = XmlReader.Create(new StringReader(projectText));
var projectRoot = ProjectRootElement.Create(xmlReader);
projectRoot.FullPath = Path.Join(Environment.CurrentDirectory, "test.csproj"); // MSBuildProjectFullPath

any <MSBuild Projects="$(MSBuildProjectFullPath);..." /> should work. Notice the FullPath is set so MSBuild knows which full path corresponds to the current virtual project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions