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

Missing Restore target when building with Microsoft.Build #892

Open
debanne opened this issue Feb 21, 2017 · 3 comments
Open

Missing Restore target when building with Microsoft.Build #892

debanne opened this issue Feb 21, 2017 · 3 comments
Milestone

Comments

@debanne
Copy link

debanne commented Feb 21, 2017

I'm trying to build a .NET Core csproj using directly the Microsoft.Build API. The attempt can be seen here:
https://github.com/debanne/dotnet-builder/blob/master/Builder/Program.cs
I know that there is no nuget providing the targets (until issue #300 is solved), so I configured the "MSBuildSDKsPath" environment variable as a workaround.

My problem is that MSBuild complains when building the "Restore" target with this message:

: ERROR C:\cygwin64\home\debanne\repos\testMSBuild\Builder\Builder\bin\Debug\resources\project1\CoreApp.csproj(0,0): The target "Restore" does not exist in the project.

The "Build" target works correctly though if I have run first a "dotnet restore".
I see the Restore target is present in dotnet/sdk/1.0.0-rc4-004771/Nuget.targets. Is there a way to make the Microsoft.Build API use it?

The full output is in attachment:
builder_log.txt

@dsplaisted
Copy link
Member

Do you want this to work on a machine without MSBuild installed on it, or would it be OK if when you call the MSBuild APIs it used an installed version of MSBuild with the targets and SDK you need?

@debanne
Copy link
Author

debanne commented Feb 21, 2017

Ultimately my tool will be run on developer and CI machines. If a requirement is to install some tools like Build Tools or dotnet CLI, I'm fine with it (it will just add a requirement to the configuration of the machine).
I noticed that my code is already calling the external compiler of Build Tools:

Csc: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Roslyn\csc.exe

I have just uninstalled Build Tools 2017 RC, and the compiler from Visual Studio is now used:

Csc: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Roslyn\csc.exe

Another consequence is that the "Restore" target is now working.
The problem is that Visual Studio 2017 cannot be a requirement for the CI machines.

@rainersigwald
Copy link
Member

Right now, the Build Tools installer doesn't have a checkbox to enable .NET Core scenarios. Ideally it would, but that will have to wait until some post-RTW release.

Setting MSBuildSdksPath isn't sufficient because the Build Tools copy of Visual Studio also doesn't have NuGet installed, which is how the Restore target is delivered to the individual projects.

The only current ways to get the Sdk + NuGet installed in the right place relative to MSBuild is through the VS installer (for full-framework MSBuild) and through the dotnet CLI installation (for .NET Core MSBuild).

@livarcocc livarcocc added this to the 2.0 M1 milestone Apr 19, 2017
@livarcocc livarcocc modified the milestones: 2.1.0, 2.2.0 May 25, 2017
mmitche pushed a commit to mmitche/sdk that referenced this issue Jun 5, 2020
…0190820.2 (dotnet#892)

- Microsoft.AspNetCore.Mvc.Analyzers - 5.0.0-alpha1.19420.2
- Microsoft.AspNetCore.Mvc.Api.Analyzers - 5.0.0-alpha1.19420.2
- Microsoft.AspNetCore.Analyzers - 5.0.0-alpha1.19420.2
- Microsoft.AspNetCore.Components.Analyzers - 5.0.0-alpha1.19420.2
@marcpopMSFT marcpopMSFT modified the milestones: 2.3.0, Backlog Aug 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants