Unable to deploy app with nuget references on server - azure

I am having a hard time deploying my first .net core app with nuget references on the server. Locally, the app works absolutely fine (able to use nuget packages).
Apparently, there is no packages.config. I am using Dapper, Newtonsoft.Json, etc. Where is the project storing reference to these packages? There is no packages folder.
In the solutions folder, there is nuget.config file which for some reason is empty.
What should I add here

Unable to deploy app with nuget references on server
That because you are using the old version nuget restore task in the build pipeline, which only supports for the package management type packages.config not PackageReference.
That the reason why the old version task ask you to provide the path to the packages.config. The PackageReference is a follow-up product, so the previous version of nuget restore task does not support it.
Check the blog for some more details.
To resolve this issue, please use the V2 of the nuget restore task:
Note:
The PackageReference needs the nuget.exe 4.1 and above, please add
a NuGet tool installer to install the nuget version above 4.1.
Using .NET Core restore task should be also work for this issue.
Update:
Yes, using TFS 2016
Since you are using TFS 2016, you could try to use the command line to invoke the nuget.exe to restore the package instead of the nuget installer task:
Download the nuget.exe above 4.0 from the nuget.org, then set it on the TFS server.
Hope this helps.

You need to create a NuGet.config file that points to whatever NuGet feed you're using, add it to source control, and reference it in your build. I'll use the official feed for my example. This feed is already present by default if you're developing using Visual Studio, which might explain why the build runs locally but not on Azure DevOps.
At the very least, your NuGet.config file needs to look like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="NuGet.org Feed" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
In .NET Core, packages are now stored globally in your User directory. packages.config has been dropped in favor of the PackageReference node in a project file, so check your csproj to see the NuGets you're referencing.

You should use task dotnetcorecli task which has
#command: 'build' # Options: build, push, pack, publish, restore, run, test, custom

Related

Could not load file or assembly 'Microsoft.Azure.WebJobs.Host, Version=3.0.22.0

I have recently cloned a new repository which has AzureFunctions but I am unable to run it. The build succeeds and on Run click it opens a window suggesting that it is downloading Azure
I am using VS2017 and .Net core 2.1.
It seems to be working for other team members but not for me.
I keep getting this 'Could not find Azure.WebJobs.Host...' error continuously.
I've tried all the fixes that are there on the internet without any luck.
The Azure Functions and Web job tools dlls seem to be up-to-date as they are not shown in the updates tab.
Updating all the nuget dependencies also did not work.
I tried using VS2017 and .Net core 2.1.
Installed Microsoft.Azure.WebJobs - 3.022 version from Nuget Packages.
Included Namespace
using Microsoft.Azure.WebJobs.Host;
I found that there is no Microsoft.Azure.WebJobs.Host direct assembly to include.
If you install Microsoft.Azure.WebJobs you can directly use Microsoft.Azure.WebJobs.Host namespace.
Check your .csproj , if you have any PackageReference Included with Microsoft.Azure.WebJobs.Host, try to remove and build your Application.
It must include Microsoft.Azure.WebJobs

update or downgrade .csproj file after nuget restore packages from packages.config

I have many VSTS builds which has reference to one nuget package. Depending on primiary build we have to sometimes to upgrade/downgrade nuget package in VSTS build. We are doing this by copying packages.config with proper version, then we use nuget restore. My problem is that after upgrade/downgrade of nuget package .csproj file still have old version od package reference, so when build starts it still try to search for old reference from .csproj file and build fails.
I there any way to change .csproj file after nuget restore?
No, there is no way to update the .csproj during the build. You should change the .csproj locally and then build in VSTS.
Except the way manually changed the .csproj file, there has an easier way to change package versions correspondingly in .csproj. Execute below command in Package Manager Console window:
update-package -reinstall
So the workflow to use upgrade/downgrade nuget package version as below:
Change the versions in package.config file.
Run the command update-package -reinstall in in Package Manager Console window.
Commit and push/checkin the changes to remote repo.
Build your project in VSTS with the upgrade/downgrade nuget package version reference.

SlowCheetah 2.5.48 not transforming web config on build

So I have downloaded the latest SlowCheetah Visual Studio Extension v2.5.48.45331 and installed the latest NuGet Package. I have a custom build configuration named XL.Production and have the according Web.XL.Production.config file. When I publish, Web.XL.Production.config is picked up and everything's sugar, but when I hit F5, no go, Web.config settings are used even though XL.Production configuration is currently selected.
I have checked out this question: SlowCheetah not transforming file on build
But the latest SlowCheetah is not using PropertyGroup any longer and instead relies on the NuGet Package.
So it's not working for me, it was clean install, we never had any previous version of SlowCheetah installed. We are using VS2013 w/Update 5.
p.s. Just a thought, why is such a critical functionality not built in into VS by default? Why should I have to install a NuGet package and a Visual Studio Extension to get this to work?

Tfs and nuget: project files are forever in check out after build with restore nuget packages

MS VS 2012
I have solution in tfs with enabled nuget packages restore. Every time when I build solution all my project files are cheked out with this changes:
<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>
How to fix this behaviour?
As of NuGet v2.7, MSBuild-Integrated Package Restore has been deprecated and replaced with Automatic Package Restore.
See documentation on how to migrate your solution to the new feature: Migrating MSBuild-Integrated solutions to use Automatic Package Restore
To learn more about Automatic Package Restore see
NuGet Package Restore
Both articles discuss how this effects TFS integration.

NuGet Package restore failed for project myProjectWeb: Unable to find version '3.0.1' of package 'AppForSharePoint16WebToolkit'

It's a provider hosted project. It used to work until very recently.
If I create a completely new project/solution, then it works.
If I start the old one, or redownload it from source control, I get the following error:
NuGet Package restore failed for project LocalTheaterWeb: Unable to find version '3.0.1' of package 'AppForSharePoint16WebToolkit'
I tried Update-Package -Reinstall but the problem stays.
Any ideas?
The solution of Scott Hillier did it for me:
http://www.shillier.com/archive/2014/08/05/nuget-package-restore-fails-for-sharepoint-2013-provider-hosted-apps.aspx
I often take advantage of the NuGet Package Restore capability to
reduce the size of my projects when saving or sharing them. Today, I
discovered an issue with this process when building SharePoint 2013
Provider-Hosted Apps against SharePoint Online. Here are the steps to
reproduce and the fix:
Create a Provider-Hosted App in Visual Studio 2013 using a SharePoint Online site for debugging.
Right click solution and "Enable NuGet Package Restore"
Save and Close Project
Delete the “packages” folder from project directory
Open Project in Visual Studio 2013
Rebuild, receive error “Unable to find AppForSharePoint16WebToolkit”
Open Packages.config file
Change “AppForSharePoint16WebToolkit” to “AppForSharePointWebToolkit”
Rebuild – successfully this time. Apparently, the "AppForSharePoint16WebToolkit" package is not available through the
NuGet Package Manager, but the older "AppForSharePointWebToolkit"
package is available.
The error message suggests that NuGet cannot find the AppForSharePoint16WebToolkit package in your package sources. So check the following:
The correct package source is selected whilst doing the Update-Package -Reinstall.
Check the package source that hosts the NuGet package is enabled. If you are using a recent version of NuGet the package restore should use all the enabled package sources.
See if the solution or project has its own NuGet.config which is overriding the package sources.
Without further information my guess is 3. since you say it works for a new project.
You can also run Fiddler to see what package sources NuGet is using as it tries to restore.
For older "locked down" projects with specific package version numbers that you can't update, un-check "Automatically check for missing packages during build in Visual Studio" which is found via:
Nuget Package Manager > Package Manager Settings
This means that if you toggle between newer projects and older projects you need to check and un-check this setting

Resources