MSBuild to publish Web Application project VS2019

Owen Mortensen 1 Reputation point
2021-08-03T18:15:09.233+00:00

We are trying to build and publish our Web Application Project using MSBuild (using a separate Build machine from our developers!) I got MSBuild working and publishing on a developer machine with Visual Studio 2019 installed. However, when cloning the project onto the build machine (from github), installing MSBuild 2019 (with web development workload), I get the following nasty error:

error: This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.

So, NuGet is not installed.... Tried dotnet restore, but that gives the following: Nothing to do. None of the pronects specified contain packages to restore.

I've seen several posts in other places that say "just install Visual Studio on the build machine"... License issue?

TIA,
Owen

.NET CLI
.NET CLI
A cross-platform toolchain for developing, building, running, and publishing .NET applications.
326 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
37,416 questions
{count} votes

1 answer

Sort by: Most helpful
  1. PengGe-MSFT 3,341 Reputation points
    2021-08-04T03:09:19.563+00:00

    Hi, @Owen Mortensen

    Welcome to Microsoft Q&A!

    You can refer to this document to restore packages.
    You can also try to remove these contents in the proj file:

    <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />  
    <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">  
      <PropertyGroup>  
        <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>  
      </PropertyGroup>  
      <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />  
    </Target>  
    

    Sincerely,
    Peng
    *
    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread

    0 comments No comments