Azure Pipeline deploy to Web App Service failing with Missing required property 'OutputPath' - c#

I am running into an issue with deploying to Azure Web App resource I've got set up. I can't find much about this error online so posting here...
I have a .NET solution with a main project and several class library projects which i make references to in my main project.
For some reason, the deployment is failing because it doesn't pick up those dll projects in the solution. My code is on a bitbucket repo and I've set it to deploy to my web app resource whenever I make a commit to a certain branch.
But it is failing with this error:
Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling .NET Web Application deployment.
MSBuild auto-detection: using msbuild version '14.0' from 'D:\Program Files (x86)\MSBuild\14.0\bin\amd64'.
All packages listed in packages.config are already installed.
Invalid restore input. Missing required property 'OutputPath' for project type 'PackageReference'. Input files: D:\home\site\repository\XXXCode\XXXXX.Entities\XXXXX.Entities.csproj.
Failed exitCode=1, command=nuget restore "D:\home\site\repository\XXXCode\XXXCode.sln"
An error has occurred during web site deployment.
Invalid restore input. Missing required property 'OutputPath' for project type 'PackageReference'. Input files: D:\home\site\repository\XXXCode\XXXXX.Entities\XXXXX.Entities.csproj.\r\nD:\Program Files (x86)\SiteExtensions\Kudu\82.10503.3890\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"
Am i missing a step here?
I'm new to this so I probably forgot a step somewhere.
Any help greatly appreciated, thanks!

MSBuild auto-detection: using msbuild version '14.0' from 'D:\Program
Files (x86)\MSBuild\14.0\bin\amd64'.
According to this error message, apparently the version you are using is MSBuild 14.0(VS 2015 tools).
And also, from this message:
Missing required property 'OutputPath' for project type
'PackageReference'.
As far as I understood, the PackageReference just works with MSBuild version 15 and higher, instead of 14.0. Since it came with VS 2017, and at the same time MSBuild 15.0.
So, for solve this error, I recommend you try with the newer version: MSbuild 15.0.
You can also refer to this ticket: Missing required property 'OutputPath' for project type 'PackageReference'
Edit:
First, please ensure that your script can be executed successfully in VS2017 locally.
And then, if you build with Visual Studio build task, change the Visual Studio Version as:
Or, if its MSBuild task you are using, just need to change the MSBuild Version:
On the other hand, if you are using Specify Location instead of Version in MSbuild task, specify the location path of MSBuild.exe which under MSBuild 15.0. For me, I am using VS2019, so the location of MSbuild 16.0 is:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe
Update:
Since you are using VS2017, you can specified the location of MSbuild 15.0 with your MSbuild 15.0 file path as:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64

Related

How to build MAUI.NET solution with few projects into standalone exe file

I have solution - MAUI.NET application that has references to other projects in this solution. I have created them all for .NET 6 and all of them were upgraded to .NET 7.
I need to ship this application as .exe file to the user. I found a nice command I am trying to execute in Developer Command Prompt for VS 2022:
msbuild /restore /t:build /p:TargetFramework=net7.0-windows10.0.19041 /p:configuration=release /p:WindowsAppSDKSelfContained=true /p:Platform="Any CPU" /p:WindowsPackageType=None /p:RuntimeIdentifier=win10-x64
also I proceed this with dotnet restore and msbuild /restore.
I also did addition of <WindowsPackageType>None</WindowsPackageType> into .csproj of the main project in solution and changed "commandName" in launchSettings.json into Project.
Visual Studio was updated yesterday - 17.4.5. NuGet package manage is 6.4.0 version.
The application runs in debug well.
Is it possible to build this for Windows as .exe that can be moved away (without the whole stuff in /bin)?
What else I miss to build this way?
I am getting an errors like follows:
C:\Program Files\dotnet\sdk\7.0.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1005: Assets file 'C:\...\obj\project.assets.json' doesn't have a target for 'net7.0-windows10.0.19041.0'. Ensure that restore has run and that you have included 'net7.0-windows10.0.19041.0' in the TargetFrameworks for your project.
C:\Program Files\dotnet\sdk\7.0.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1005: Assets file 'C:\...\obj\project.assets.json' doesn't have a target for 'net7.0'. Ensure that restore has run and that you have included 'net7.0' in the TargetFrameworks for your project.

Why can't I compile any of my old or new project? [duplicate]

I just upgraded my visual studio 2019 to latest version 16.8.3 and suddenly I am not able to load any C# project and getting the following error for all .NET core projects:
The project file cannot be opened. Unable to locate the .NET SDK.
Check that it is installed and that the version specified in
global.json (if any) matches the installed version.
Try to edit envrionment Variables.
Right click on This PC -> Properties -> Advanced System Settings -> Advanced -> Environment Variables -> System Variables
Add [install path] C:\Program Files\dotnet\ to the variable path.
Restart visual studio.
If it does not solve this problem, you can refer to this answer.
I found that the path C:\Program Files\dotnet was already in my path but it was ordered below the C:\Program Files (x86)\dotnet entry. By simply moving C:\Program Files\dotnet above C:\Program Files (x86)\dotnet in the list and restarting Visual Studio cleared up the problem.
If there is a global.json file in your solution folder(where *.sln file reside), delete this.
In my case, I had .NET 6 preview but then uninstalled it. After uninstalling, some of my projects won't load. I have all the configurations mentioned above but still won't load the projects. I went to C:\Program Files\dotnet\sdk\ where I found that there still exist a .NET 6 folder which is empty. Deleting that empty .NET 6 folder fixes the issue and I was able to load my projects.
This works for me...
Check first if which .net Core SDK is available in the system.
Step 1: Open Command prompt (CMD) and type dotnet --info
The above image shows no SDK is installed or register
Step 2: Install SDK from https://dotnet.microsoft.com/download/dotnet-core
Done Visual studio works like charm... Verify if its properly installed and register
Above image you can see .net core SDK is registered properly on the system.
I had a similar situation upgrading from VS 2019 to VS 2022, trying to run a dotnet 5.0 solution from VS 2022 (that starts to use dotnet 6.0).
In the PATH env. variable I had both 'C:\Program Files\dotnet' and 'C:\Program Files (x86)\dotnet'. I removed the (x86) one and stopped having that error
Installing missed SDK that the project has built solved the problem
I had a similar issue when I tried to build a net5.0 solution that is not installed on my machine.
In my case, I had VS 2022, and net6.0 installed.
Installing net5.0 SDK solved the problem.
I had only C:\Program Files\dotnet in Path env
I just carefully followed the error message and tried to resolve the problem.
I got below error message:
F:\mypath\ServerlessFunc\ServerlessFunc\ServerlessFunc.csproj : error
: The project file cannot be opened. C:\Program
Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\Sdk not found. Check
that a recent enough .NET SDK is installed and/or increase the version
specified in global.json.
I then tried to navigate through
C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\Sdk
path which was mentioned in the above error and found that the above path does not exist. This problem could be resolved if I install SDK of version of 6.0. Rather I started using VS-2022.

Microsoft Visual Studio 2019: The project file cannot be opened. Unable to locate the .NET SDK

I just upgraded my visual studio 2019 to latest version 16.8.3 and suddenly I am not able to load any C# project and getting the following error for all .NET core projects:
The project file cannot be opened. Unable to locate the .NET SDK.
Check that it is installed and that the version specified in
global.json (if any) matches the installed version.
Try to edit envrionment Variables.
Right click on This PC -> Properties -> Advanced System Settings -> Advanced -> Environment Variables -> System Variables
Add [install path] C:\Program Files\dotnet\ to the variable path.
Restart visual studio.
If it does not solve this problem, you can refer to this answer.
I found that the path C:\Program Files\dotnet was already in my path but it was ordered below the C:\Program Files (x86)\dotnet entry. By simply moving C:\Program Files\dotnet above C:\Program Files (x86)\dotnet in the list and restarting Visual Studio cleared up the problem.
If there is a global.json file in your solution folder(where *.sln file reside), delete this.
In my case, I had .NET 6 preview but then uninstalled it. After uninstalling, some of my projects won't load. I have all the configurations mentioned above but still won't load the projects. I went to C:\Program Files\dotnet\sdk\ where I found that there still exist a .NET 6 folder which is empty. Deleting that empty .NET 6 folder fixes the issue and I was able to load my projects.
This works for me...
Check first if which .net Core SDK is available in the system.
Step 1: Open Command prompt (CMD) and type dotnet --info
The above image shows no SDK is installed or register
Step 2: Install SDK from https://dotnet.microsoft.com/download/dotnet-core
Done Visual studio works like charm... Verify if its properly installed and register
Above image you can see .net core SDK is registered properly on the system.
I had a similar situation upgrading from VS 2019 to VS 2022, trying to run a dotnet 5.0 solution from VS 2022 (that starts to use dotnet 6.0).
In the PATH env. variable I had both 'C:\Program Files\dotnet' and 'C:\Program Files (x86)\dotnet'. I removed the (x86) one and stopped having that error
Installing missed SDK that the project has built solved the problem
I had a similar issue when I tried to build a net5.0 solution that is not installed on my machine.
In my case, I had VS 2022, and net6.0 installed.
Installing net5.0 SDK solved the problem.
I had only C:\Program Files\dotnet in Path env
I just carefully followed the error message and tried to resolve the problem.
I got below error message:
F:\mypath\ServerlessFunc\ServerlessFunc\ServerlessFunc.csproj : error
: The project file cannot be opened. C:\Program
Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\Sdk not found. Check
that a recent enough .NET SDK is installed and/or increase the version
specified in global.json.
I then tried to navigate through
C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\Sdk
path which was mentioned in the above error and found that the above path does not exist. This problem could be resolved if I install SDK of version of 6.0. Rather I started using VS-2022.

MSBuild error MSB3155 on Jenkins

I am trying to build and publish a .net application through MSBuild in a Jenkins CI Server, and I am getting the errors bellow
warning MSB3155: Item 'Microsoft.Sql.Server.Express.9.2' could not be located in
warning MSB3155: Item 'Microsoft.Net.Framework.2.0' could not be located in
Does anybody know how to fix this problem? How could I install those components into my Bootstrapper files? (there is nothing at C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bootstrapper)
I am using MSBuild 4.0 (because the solution was created in vs2010) and the target framework is 2.0.
Thanks
I solved this issue by installing a x64 version of the Microsoft Windows SDK...so the corretc path is C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper = Without the (x86) string.

Need to msbuild C# project of lower version on commandline, without Visual Studio

I need to msbuild C# project of lower version on commandline, I donot have Visual Studios.
I am facing the error while building the project:
Microsoft (R) Build Engine Version 2.0.50727.42
[Microsoft .NET Framework, Version 2.0.50727.42]
Copyright (C) Microsoft Corporation 2005. All rights reserved.
.\Project.sln : Solution file error MSB4054: The solution file must be opened in t
he Visual Studio IDE and converted to the latest version before it can be built
by MSBuild.
I have the .sln file and previously someone did build the project from here possibly with the Version 1.0 engine.
Can someone help me with this?
You'll find MSBuild in C:\Windows\Microsoft.NET\Framework[framework version].
For instance, the one that came with .NET 2.0 is in C:\Windows\Microsoft.NET\Framework\v2.0.50727. I believe that's the one that came with VS 8.0.
If you need the x64 version, it's in C:\Windows\Microsoft.NET\Framework64\v2.0.50727
In many cases you can just pass the project file to MsBuild and it will compile just fine. Forexample:
msbuild MyProj.csproj /p:Configuration=Release
.csproj files are valid MsBuild XML files whereas .sln files have to be converted into MsBuild scripts on the fly, which is why they are tied to a specific version of Visual Studio.
If you have multiple projects in your solution I would recommend passing the primary/startup project to MsBuild so that all of the dependencies also get built. This method does not always work and you may run into problems is if you have any solution level dependencies or custom solution configurations specified in the solution file.
Ok, got permission from client to install VStudios. Installed and built the program :/

Categories

Resources