MsBuild failing for .Net Standard project with error "Package System.Security.Cryptography.ProtectedData, version x.x.x was not found" - msbuild

Project Setup : Mixed framework solution
.Net Framework 4.6.2 projects in solution : 15
.Net Standard 2.0 projects in solution - 1
Development Machine
Visual Studio 2017(15.7.4) : Builds without any errors
Build Server
TeamCity Version 2017.1.3
Build Steps
Nuget Restore(3.4.4)
dotnet Restore
MSBuild( Build Tools 2017), Tools Version 15.0
Build fails with following error in the .net standard 2.0 project : [ResolvePackageAssets] C:\Program Files\dotnet\sdk\2.1.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198, 5): Package System.Security.Cryptography.ProtectedData, version 4.4.0 was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions.
What's interesting is I can't find reference or use of System.Security.Cryptography.ProtectedData anywhere in the project. Any help is greatly appreciated.
P.S - Can't use dotnet build, as the solution needs building of licenses.licx files, and the component which builds it (Microsoft.Build.Tasks.LC) is not ported to .Net Core. The suggestion from various posts was to use MsBuild.exe

Related

Correct .NET Core SDK to build netstandard20 library

I have a few libraries with target framework netstandard20. These libraries are consumed by a few .net framework 4.6.1 libraries.
The IT department uninstalled the .NET Core 2.0 from the build server because of some security vulnerability. All the libraries that use netstandard20 are now failing with the following error:
C:\bamboo6104...>nuget restore
MSBuild auto-detection: using msbuild version '16.11.2.50704' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\bin'.
C:\bamboo6104\xml-data\build-dir\BAM-CUS-JOB1...\netstandard\xxx.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found.
The Build Server already has Visual Studio 2019. What version of SDK need to be installed for the build to pass? I have the following SDKs on my laptop:
Will installing 2.1.526 version resolve the build issue?
I can't upgrade the libraries to .NET 5 or 6 due to we have numerous libraries with the same problem and upgrade is not a priority.

Appveyor CI fails to build a .net core 2.1 solution with a database project

Our .net core 2.1 solution compiles fine on our local development machines with .net core sdk 2.1.301. Appveyor used to compile the solution in its CI pipeline when there was no database projects defined. Once such a project added, Appveyor started failing in building the solution with the error message below. Any clues how to address this issue?
C:\projects\comingsoon\ComsingSoonDatabase\ComsingSoonDatabase.sqlproj(57,3):
error MSB4019: The imported project "C:\Program
Files\dotnet\sdk\2.1.300\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets"
was not found. Confirm that the path in the declaration is
correct, and that the file exists on disk.
The database project can only be built using the full framework MSBuild tools included in visual studio.
Depending on how you set up appveyor, you need to change your definition to use msbuild.exe instead of dotnet commands.

Visual Studio 15.3.1 can't find core DLLs after update

I'm getting the runtime error:
InvalidOperationException: Can not find assembly file mscorlib.dll at '...\bin\Debug\net462\refs,...\bin\Debug\net462\'
This had not been a problem until I updated to version 15.3.1 this morning, and installed the .Net Core 2.0 SDK.
The DLL's are present in my ~\.nuget\packages folder. I'd had the same issue with the "Microsoft.Csharp.dll" assembly until I copied and pasted it into the stated folder.
I tried specifying to use .Net Core 1.1.0 via a global.json file, but then I get the build error:
The version of Microsoft.NET.Sdk used by this project is insufficient to support references to libraries targeting .NET Standard 1.5 or higher. Please install version 2.0 or higher of the .NET Core SDK.
This error goes away if I clean the solution then restore Nuget packages via Command Line- not via the GUI. However it comes back if I change the version of a nuget package.
OK, this seem slightly different to my issue here: Visual Studio update 2017 15.3.1 forces ASP.NET Core SDK 2.0, which then doesn't find "reference assemblies"
If you install the SDK 2.0 from https://www.microsoft.com/net/download/core
You will then "probably" be able to build and run the project again but you'll be back to having the missing Microsoft.CSharp.dll / mscorelib.dll error.
If you then make sure the dependency is correct for the netstandard version:
<DependsOnNETStandard>netstandard1.5</DependsOnNETStandard>
See here: https://learn.microsoft.com/en-us/dotnet/standard/net-standard for the right version for you. My project is using core 1.1 targeting the full framework 4.6.1 and targeting netstandard1.6 has worked for me.
The final piece of the puzzel, was found on the GitHub issues here: https://github.com/dotnet/sdk/issues/1488
Add the following to your references in the .csproj file:
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="2.0.0" />
This will then build the project as a 1.1 project, but using the 2.0 SDK (which from what I can tell, it's supposed to do!). I can now run the project, update packages and generally got on with my work!

ASP.Net Core 1.1 - Migration Failure

I know VS 2017 is only RC but there seem to be some major issues with migrating an ASP.Net Core 1.0 project to 1.1. The migration tool fails converting 2 of my 8 projects in the solution (I prefer to adopt a layered architectural approach for my projects) the sample project is located here. One project in particular is the class library I moved my web api controller methods into. In trying to re-create this class library it doesn't seem one is able to declare a controller class after installing Microsoft.AspNetCore.Mvc nuget. It is installed but the compiler is not finding the Controller, RouteAttribute classes, etc. The same issue occured with trying to setup a DI layer IServiceCollection. Nuget Microsoft.Extensions.DependencyInjection doesn't seem to be doing it.
The migration log quite honestly isn't really helping me. It seems to indicate an issue with my service project and the project.json file but as you can tell it is in the repository.
It feels like Microsoft is forcing us down the path of cramming all the "web" stuff into a single project file. Maybe these tools aren't far enough along yet but an RC would indicate they should be closer to ship ready?
ReciPiBook.Api
Message
src\ReciPiBook.Api\ReciPiBook.Api.xproj: Failed to migrate XProj project ReciPiBook.Api. 'dotnet migrate -s -p "C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook2017\ReciPiBookCore\src\ReciPiBook.Api" -x "C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook2017\ReciPiBookCore\src\ReciPiBook.Api\ReciPiBook.Api.xproj"' exited with error code 1.
src\ReciPiBook.Api\ReciPiBook.Api.xproj: Could not find file 'C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook2017\ReciPiBookCore\src\ReciPiBook.Services\project.json'. Migration failed.
src\ReciPiBook.Api\ReciPiBook.Api.xproj: Backing up C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook2017\ReciPiBookCore\src\ReciPiBook.Api\ReciPiBook.Api.xproj to C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook2017\ReciPiBookCore\Backup\src\ReciPiBook.Api\ReciPiBook.Api.xproj.
src\ReciPiBook.Api\project.json: Backing up C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook2017\ReciPiBookCore\src\ReciPiBook.Api\project.json to C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook2017\ReciPiBookCore\Backup\src\ReciPiBook.Api\project.json.
I can't directly speak to VS2017 as I'm staying away from it as even though it's a RC, the core tooling is in ALPHA. The VS 2015 core tooling is at least in a "RC" state (actually only preview).
In VS2015 I migrated from 1.0.x to 1.1 manually (per https://blogs.msdn.microsoft.com/dotnet/2016/11/16/announcing-net-core-1-1/):
Download the 1.1 sdk
Change your global.json "sdk":{"version": "1.0.0-preview2-1-003177"} (yes it's a different version string).
Update all the project.json package versions from 1.0 to 1.1 (some are preview some arn't). Just open up the nuget package manager, allow preview versions, then install all the updates.
Fix any of your project.json tool entries as the package manager clobbers those.

MSBuild error - Solution is of version 12.00 which is not currently supported

I have a Build server which has TFS 2010 Build Service installed. I have 2 Build Agents and 1 Controllers configured. One of our projects have been converted to Visual Studio 2012.
I found out that .NET framework 4.5 comes with new version of MSBuild which is version 4.5.
I installed .NET framework 4.5 on the Build Server because prior to installing it every time the project was built I kept getting the following error:
"Solution is of version '12.00' which is not currently supported".
After installing .NET 4.5, I still run into the same issue.
How could I go about resolving this?
Do I have to configure the Build Agent to use the new MSBuild 4.5 in order to build this particular project or do I set something in the projects solution file itself? If so how?
I would really appreciate if somebody could assist me with this please?
Try install vs2012 on the build server, while i don't believe it's strictly needed it's the easiest way to get all the requirements installed.
We have installed VS2012 on the build agent. Interestingly when I RDC to the build agent and then run msbuild from the command line everything works fine. So the issue looks like it happens before we even get to MSBuild.