dotnet publish, Core project with framework references, fails with release configuration - .net-5

Publishing in release configuration gives this error:
Microsoft.Bcl.Build.targets(97,5): error MSB4062: The
"EnsureBindingRedirects" task could not be loaded from the assembly
...\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.Tasks.dll.
Could not load file or assembly 'Microsoft.Build.Utilities.v4.0,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
The system cannot find the file specified. Confirm that the
<UsingTask> declaration is correct, that the assembly and all its
dependencies are available, and that the task contains a public class
that implements Microsoft.Build.Framework.ITask
This is my publish command:
dotnet publish .\MyProject.csproj --runtime win10-x64
--self-contained --configuration release
If I omit the configuration parameter the build is successful.
Building with Visual Studio (msbuld) works with debug or release configurations.
This is a .Net 5 project that references projects that use .Net framework 4.7.2 projects.

Related

Xamarin Forms with Visual Studio 2017

I am new to Xamarin and have created a cross-platform project in Visual Studio 2017.
When I build that project, I am getting the below issue:
Severity: Error
Code: MSB4062
Description: The "Xamarin.Forms.Build.Tasks.XamlGTask" task could not be loaded from the assembly C:\Users\E6430\.nuget\packages\xamarin.forms\3.1.0.637273\build\netstandard2.0\Xamarin.Forms.Build.Tasks.dll. Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
Project: TestApp
File: C:\Users\E6430\.nuget\packages\xamarin.forms\3.1.0.637273\build\netstandard2.0\Xamarin.Forms.targets
Line: 84
My NuGet is also get coloured with yellow colour.
Try this:
Unload project from the solution
Restart visual studio and open solution
Reload project
Rebuild
If persist:
Just run Visual studio as Administrator!
Ref: https://forums.xamarin.com/discussion/106784/error-with-latest-nuget-v2-5-0-77-xamarin-forms-build-tasks-gettasksabi-task-could-not-be-loaded

Unable to publish ASP.NET Core application with "CreateManifestFile" task could not be loaded

I have an ASP.NET Core app which I can publish using web deploy and pre-configured publishing profile via Visual Studio 2017. Now I need to configure CI and trying to achieve the same from the command line so I installed [.NET Core SDK][1] and followed this guide
dotnet build -c release /p:DeployOnBuild=true /p:PublishProfile=publish-profile-name
Unfortunately, it gives the following error:
C:\Program
Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk.Publish\build\netstanda
rd1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(227,5):
error MSB4062: The "CreateManifestFile" task could not be loaded from
the assembly C:\Program
Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0
....\tools\netcoreapp1.0\Microsoft.NETCore.Sdk.Publish.Tasks.dll.
Confirm that the declaration is correct, that the assembly
and all its dependencies are available, and that the task contains a
public class that implements Microsoft.Build.Framework.ITask.
How can I fix the dotnet build line?
If your publish profile uses MSDeploy, it cannot be built via the .NET Core based build tools (dotnet build).
See the related GitHub issue https://github.com/aspnet/websdk/issues/166
The workaround is to use msbuild /p:Configuration=Release … from a VS 2017 installation instead of dotnet build.

Can't build Xamarin Android with VS2017 MSBuild and Jenkins

Has anyone managed to build Xamarin Android apps with VS2017 MSBuild and Jenkins?
On our build machine we can build via the command prompt but when building via Jenkins we get this error.
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2371,2):
error MSB4062: The "Xamarin.Android.Tasks.GetAndroidPackageName" task
could not be loaded from the assembly C:\Program Files (x86)\Microsoft
Visual
Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Build.Tasks.dll.
Method 'get_BuildEngine' in type 'Xamarin.Android.Tasks.AsyncTask'
from assembly 'Xamarin.Android.Build.Tasks, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null' does not have an implementation.
Confirm that the declaration is correct, that the assembly
and all its dependencies are available, and that the task contains a
public class that implements Microsoft.Build.Framework.ITask
We're using a Pipeline script with the following command. The same command works fine with VS2015 MSBuild and Jenkins.
bat "${msbuild15} /consoleloggerparameters:ErrorsOnly /v:quiet
/p:Configuration=ProductionRelease /p:Platform=\"Any CPU\" /t:Rebuild
Field\Product.Android.sln"
GetAndroidPackageName
This task will be failed majorly because your manifest file gets malframed, may be that manifest xml malframed, unncessary charecters might be present.
Remove them And your issue will be solved..

Getting dnu build working on TeamCity

We're trying to get a vNext project building on TeamCity 9.16 - the project is using the dnx451 and dnxcore50 frameworks.
When TeamCity is running dnu build for DNX,Version=v4.5.1 it's erroring when trying to build System.Configuration 4.0.0 with the following error:
DNX,Version=v4.5.1 error CS0012: The type 'Action<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes
However running dnu build from the command line when logged on to the machine as the TeamCity build agent is successful (after running dnvm upgrade)
I suspect that this might be something to do with TeamCity and Paths but am at a loss as how to proceed.

Getting MSBuild and CruiseControl .NET to build and deploy VS2010 database projects

I almost have a NAnt script together that will build and deploy VS2010 database projects, but one error stands in my way:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamData\Microsoft.Data.Schema.TSqlTasks.targets(56,5): error MSB4062: The "SqlBuildTask" task could not be loaded from the assembly Microsoft.Data.Schema.Tasks.Sql, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. Could not load file or assembly 'Microsoft.Data.Schema.Tasks.Sql, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [xxx]
Failed to start MSBuild.
External Program Failed: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild.exe (return code was 1)
I can see that the Microsoft.Data.Schema assemblies are not in the MSIL GAC on the build server - is there any clean way to do this without a full-freight installation of VS2010 on the build server?
For the curious, I asked Barclay Hill at Microsoft who answered this for me:
You can’t build database projects on
machines unless they have VS or TFS
2010 installed on them. It is not a
supported scenario. You can deploy
database project build outputs without
VS/TFS installed using vsdbcmd. The
only way to do this and be in line
with the licensing and support is to
install a local copy of VS Pro or
higher on your build box if not using
TFS.

Resources