Team Foundation Server - Local Service Account missing dnx - builds fail? How to fix - visual-studio

Trying to build a simple web project (MVC 5) that runs fine from Visual Studio 2015, but fails when I build it from team foundation server 2015 using TFSBUILD (not using xaml) ...both vs and tfs are on the same machine, Windows 2012 Enterprise, VS 2015, using the local service account for TF.
It seems the local service account is missing the dnx resources so fails - and when I try to add them via a script (see answer below for the script) it gets further in the process but blows up.
UPDATE: Seems like it can't find the global.json file so is using the latest version (update2).
WARNING: Unable to locate global.json to determine using 'latest' Determining latest version 'dnx-clr-win-x86.1.0.0-rc1-update2' is
already installed in
C:\Windows\ServiceProfiles\LocalService.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update2.
But it subsequently bombs because it's actually looking for update1
Cannot find DNX runtime dnx-clr-win-x86.1.0.0-rc1-update1 in the
folder: C:\Windows\ServiceProfiles\LocalService.dnx\runtimes
I have changed the build configuration settings, replaced any reference of update1 to update2 in all files, and still it wants update1.
So my question is, what do I have to do to either 1. reconfigure TFS, or 2. Get the resources into the path of the local system account.
During the build I get the following:
GetRuntimeToolingPathTarget: Cannot find DNX runtime
dnx-clr-win-x86.1.0.0-rc1-update1 in the folder:
C:\Windows\ServiceProfiles\LocalService.dnx\runtime
C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(126,5):
Error : The Dnx Runtime package needs to be installed. See output
window for more details.
C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(126,5):
error : The Dnx Runtime package needs to be installed. See output
window for more details.
[C:\TfsData\Agents\Agent-DESKTOP-U7761A8_work\2\s\MvcMovie\src\MvcMovie\MvcMovie.xproj]
Basically it's complaining it cant find the dnx libraries in the folder C:\Windows\ServiceProfiles\LocalService.dnx\runtime . The local service profile does not have the libraries installed in C:\Windows\ServiceProfiles\LocalService.dnx\runtime.
I can install these libraries from the command line, but it only sticks those in my local user account, even with -global etc..And that the build in TFS still fails.
Results of DMVM LIST:
Active Version Runtime Architecture OperatingSystem Alias
------ ------- ------- ------------ --------------- -----
1.0.0-rc1-update1 clr x64 win
1.0.0-rc1-update1 clr x86 win
1.0.0-rc1-update1 coreclr x64 win
1.0.0-rc1-update1 coreclr x86 win
* 1.0.0-rc1-update2 clr x86 win default
1.0.0-rc1-update2 coreclr x64 win
1.0.0-rc1-update2 coreclr x86 win
I used a powershell script that installed the libraries into the local service account folders, and after that the build go further but then bombed out - seemed there were library conflicts:
2016-04-06T23:04:56.0966631Z Building WebApplication4 for
DNX,Version=v4.5.1 2016-04-06T23:04:56.5039430Z Using
Project dependency WebApplication4 1.0.0 2016-04-06T23:04:56.5039430Z
Source:
C:\TfsData\Agents\Agent-DESKTOP-U7761A8_work\3\s\WebApplication4\src\WebApplication4\project.json
2016-04-06T23:04:56.5039430Z Unable to resolve dependency
EntityFramework.Commands 7.0.0-rc1-final 2016-04-06T23:04:56.5039430Z
Unable to resolve dependency EntityFramework.MicrosoftSqlServer
7.0.0-rc1-final 2016-04-06T23:04:56.5039430Z Unable to resolve dependency Microsoft.ApplicationInsights.AspNet 1.0.0-rc1
2016-04-06T23:04:56.5039430Z Unable to resolve dependency
Microsoft.AspNet.Authentication.Cookies 1.0.0-rc1-final
2016-04-06T23:04:56.5039430Z Unable to resolve dependency
Microsoft.AspNet.Diagnostics.Entity 7.0.0-rc1-final
2016-04-06T23:04:56.5039430Z Unable to resolve dependency
Microsoft.AspNet.Identity.EntityFramework 3.0.0-rc1-final
2016-04-06T23:04:56.5039430Z Unable to resolve dependency
Microsoft.AspNet.IISPlatformHandler 1.0.0-rc1-final
2016-04-06T23:04:56.5039430Z Unable to resolve dependency
Microsoft.AspNet.Mvc 6.0.0-rc1-final 2016-04-06T23:04:56.5039430Z
Unable to resolve dependency Microsoft.AspNet.Mvc.TagHelpers
6.0.0-rc1-final 2016-04-06T23:04:56.5039430Z Unable to resolve dependency Microsoft.AspNet.Server.Kestrel 1.0.0-rc1-final
2016-04-06T23:04:56.5039430Z Unable to resolve dependency
Microsoft.AspNet.StaticFiles 1.0.0-rc1-final
2016-04-06T23:04:56.5039430Z Unable to resolve dependency
Microsoft.AspNet.Tooling.Razor 1.0.0-rc1-final
2016-04-06T23:04:56.5039430Z Unable to resolve dependency
Microsoft.Extensions.CodeGenerators.Mvc 1.0.0-rc1-final
2016-04-06T23:04:56.5498358Z Unable to resolve dependency
Microsoft.Extensions.Configuration.FileProviderExtensions
1.0.0-rc1-final 2016-04-06T23:04:56.5654146Z Unable to resolve dependency Microsoft.Extensions.Configuration.Json
1.0.0-rc1-final 2016-04-06T23:04:56.5654146Z Unable to resolve dependency Microsoft.Extensions.Configuration.UserSecrets
1.0.0-rc1-final 2016-04-06T23:04:56.5966887Z Unable to resolve dependency Microsoft.Extensions.Logging 1.0.0-rc1-final
2016-04-06T23:04:56.5966887Z Unable to resolve dependency
Microsoft.Extensions.Logging.Console 1.0.0-rc1-final
2016-04-06T23:04:56.5966887Z Unable to resolve dependency
Microsoft.Extensions.Logging.Debug 1.0.0-rc1-final
2016-04-06T23:04:56.6122983Z Unable to resolve dependency
Microsoft.VisualStudio.Web.BrowserLink.Loader 14.0.0-rc1-final
2016-04-06T23:04:56.6122983Z Using Assembly dependency
fx/mscorlib 4.0.0 2016-04-06T23:04:56.6122983Z Source:
C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5.1\mscorlib.dll
2016-04-06T23:04:56.6122983Z Using Assembly dependency
fx/System 4.0.0 2016-04-06T23:04:56.6122983Z Source:
C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5.1\System.dll
2016-04-06T23:04:56.6122983Z Using Assembly dependency
fx/System.Core 4.0.0 2016-04-06T23:04:56.6122983Z Source:
C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5.1\System.Core.dll
2016-04-06T23:04:56.6122983Z Using Assembly dependency
fx/Microsoft.CSharp 4.0.0 2016-04-06T23:04:56.6122983Z
Source: C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5.1\Microsoft.CSharp.dll
2016-04-06T23:04:56.8622811Z
[error]C:\TfsData\Agents\Agent-DESKTOP-U7761A8_work\3\s\WebApplication4\src\WebApplication4\project.lock.json(1,0):
Error NU1009: The expected lock file doesn't exist. Please run "dnu
restore" to generate a new lock file. 2016-04-06T23:04:56.8622811Z

For your question:
1. Reconfigure TFS
You can configure your build service to run with the account that dnx has been installed. I assume you are using XAML build system, you can change it from here:
2. Get the resources into the path of the local system account.
According to the error message you get after installing dnx into local service account, the dun packages weren't restored before build. So you need to add some code in your powershell script to perform a dun restore for "project.json" file to restore the dun packages.
Following is a powershell sample provided by Microsoft to install dnx runtime and restore dun packages:
# bootstrap DNVM into this session.
&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}
# load up the global.json so we can find the DNX version
$globalJson = Get-Content -Path $PSScriptRoot\global.json -Raw -ErrorAction Ignore | ConvertFrom-Json -ErrorAction Ignore
if($globalJson)
{
$dnxVersion = $globalJson.sdk.version
}
else
{
Write-Warning "Unable to locate global.json to determine using 'latest'"
$dnxVersion = "latest"
}
# install DNX
# only installs the default (x86, clr) runtime of the framework.
# If you need additional architectures or runtimes you should add additional calls
# ex: & $env:USERPROFILE\.dnx\bin\dnvm install $dnxVersion -r coreclr
& $env:USERPROFILE\.dnx\bin\dnvm install $dnxVersion -Persistent
# run DNU restore on all project.json files in the src folder including 2>1 to redirect stderr to stdout for badly behaved tools
Get-ChildItem -Path $PSScriptRoot\src -Filter project.json -Recurse | ForEach-Object { & dnu restore $_.FullName 2>1 }

Related

Unable to find package Telerik.UI.for.Xamarin with version(>=2022.1222.1)

We have a Xamarin project, and we need to start debugging on MAC. We use the MacInCloud Service.
After cloning the project from source control, I encounter the following error -> Unable to find package Telerik.UI.for.Xamarin with version(>=2022.1222.1). It appears as soon as the project is cloned and with the the 'Could not restore packages'.
What options do I have to resolve this issue?
I have tried removing the the package from the Packages directory and removed the reference in the csproj aswell.
I can't do a manual install of telerik as we do not have admin rights on MacInCloud.
The log file >This is the entire log file - Getting restore information for project /Users/user219905/Documents/GitHub/gts-mobile/GtsApp/GtsApp/GtsApp.csproj
Getting restore information for project /Users/user219905/Documents/GitHub/gts-mobile/GtsApp/GtsApp.iOS/GtsApp.iOS.csproj
Getting restore information for project /Users/user219905/Documents/GitHub/gts-mobile/GtsApp/GtsApp.Android/GtsApp.Android.csproj
Running restore with 4 concurrent jobs.
Reading project file /Users/user219905/Documents/GitHub/gts-mobile/GtsApp/GtsApp/GtsApp.csproj.
Restoring packages for /Users/user219905/Documents/GitHub/gts-mobile/GtsApp/GtsApp/GtsApp.csproj...
Restoring packages for .NETStandard,Version=v2.0...
GET https://api.nuget.org/v3-flatcontainer/telerik.ui.for.xamarin/index.json
GET https://nuget.devexpress.com/xRMAAuTIJGNTlKc1O83zlgVKkkr2ibgsDfUBelIIfu3Oq2Ku77/api/FindPackagesById()?id='Telerik.UI.for.Xamarin'&semVerLevel=2.0.0
GET https://api.nuget.org/v3-flatcontainer/telerik.ui.for.xamarin.datagrid/index.json
GET https://nuget.devexpress.com/xRMAAuTIJGNTlKc1O83zlgVKkkr2ibgsDfUBelIIfu3Oq2Ku77/api/FindPackagesById()?id='Telerik.UI.for.Xamarin.DataGrid'&semVerLevel=2.0.0
NotFound https://api.nuget.org/v3-flatcontainer/telerik.ui.for.xamarin.datagrid/index.json 172ms
OK https://api.nuget.org/v3-flatcontainer/telerik.ui.for.xamarin/index.json 173ms
OK https://nuget.devexpress.com/xRMAAuTIJGNTlKc1O83zlgVKkkr2ibgsDfUBelIIfu3Oq2Ku77/api/FindPackagesById()?id='Telerik.UI.for.Xamarin.DataGrid'&semVerLevel=2.0.0 367ms
OK https://nuget.devexpress.com/xRMAAuTIJGNTlKc1O83zlgVKkkr2ibgsDfUBelIIfu3Oq2Ku77/api/FindPackagesById()?id='Telerik.UI.for.Xamarin'&semVerLevel=2.0.0 502ms
Resolving conflicts for .NETStandard,Version=v2.0...
Unable to find package Telerik.UI.for.Xamarin with version (>= 2022.1.222.1)
Found 1 version(s) in nuget.org [ Nearest version: 2015.3.1202 ]
Found 0 version(s) in DevExpress
Unable to find package Telerik.UI.for.Xamarin.DataGrid. No packages exist with this id in source(s): DevExpress, nuget.org
Package 'Microsoft.Bcl 1.1.10' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
Package 'Microsoft.Net.Http 2.2.29' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
Package restore failed. Rolling back package changes for 'GtsApp'.

Publish a Windows Application Package Project via command line

How can I publish the UWP package via command line?
I have a WPF application that is packaged with a Windows Application Package Project that ends up being published to the Microsoft Store.
In order to be accepted in the Store, the WPF project needs to be compiled with a preprocessor directive (that I named as "UWP"), deactivating stuff that are not allowed for Store apps.
I'm in the process of migrating the WPF app from .NET Framework 4.8 to .NET 5 and along with that I'm trying to streamline my publishing process via command line.
Is there any way to configure or update the package to support ARM64?
The app will be published outside the Store as x86, x64 and ARM64 and I intend to do the same for the Store version.
When checking the WAPP, I noticed that ARM64 is not available on the list. As you can see in the screenshot, I was able to create a ARM64 build profile, but the architecture is not available on the table.
What have I tried? (Command line issue)
I tried running this command:
MSBuild.exe C:\Project-UWP\Project.UWP\Project.UWP.wapproj /p:DefineConstants=UWP /p:Configuration=Release;AppxBundle=Always;AppxBundlePlatforms="x86|x64|ARM64" /p:OutDir="..\Publish\UWP"
But got these errors:
Microsoft (R) Build Engine version 16.11.0+0538acc04 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 29/09/2021 22:09:19.
Project "C:\Project-UWP\Project.UWP\Project.UWP.wapproj" on node 1 (default targets).
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1718,5): warning NU1702: ProjectReference 'C:\Project\Project.csproj' was resolved using '.NETCoreApp,Version=v6.0' instead of the project target framework '.NETFramework,Version=v4.5.1'. This project may not be fully compatible with your project. [C:\Project-UWP\Project.UWP\Project.UWP.wapproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1718,5): warning NU1702: ProjectReference 'C:\Project\Project.csproj' was resolved using '.NETCoreApp,Version=v6.0' instead of the project target framework '.NETFramework,Version=v4.5.1'. This project may not be fully compatible with your project. [C:\Project-UWP\Project.UWP\Project.UWP.wapproj]
_ResolveVCLibDependencies:
Searching for SDKs targeting "UAP, 10.0.20348.0".
Project "C:\Project-UWP\Project.UWP\Project.UWP.wapproj" (1) is building "C:\Project\Project.csproj" (2:9) on node 1 (publish target(s)).
C:\Program Files\dotnet\sdk\5.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1047: Assets file 'C:\Project\Project\obj\project.assets.json' doesn't have a target for 'net5.0-windows/win-x86'. Ensure that restore has run and that you have included 'net5.0-windows' in the TargetFrameworks for your project. You may also need to include 'win-x86' in your project's RuntimeIdentifiers. [C:\Project\Project.csproj]
Done Building Project "C:\Project\Project.csproj" (publish target(s)) -- FAILED.
Done Building Project "C:\Project-UWP\Project.UWP\Project.UWP.wapproj" (default targets) -- FAILED.
Build FAILED.
"C:\Project-UWP\Project.UWP\Project.UWP.wapproj" (default target) (1) ->
(_GetProjectReferenceTargetFrameworkProperties target) ->
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1718,5): warning NU1702: ProjectReference 'C:\Project\Project.csproj' was resolved using '.NETCoreApp,Version=v6.0' instead of the project target framework '.NETFramework,Version=v4.5.1'. This project may not be fully compatible with your project. [C:\Project-UWP\Project.UWP\Project.UWP.wapproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1718,5): warning NU1702: ProjectReference 'C:\Project\Project.csproj' was resolved using '.NETCoreApp,Version=v6.0' instead of the project target framework '.NETFramework,Version=v4.5.1'. This project may not be fully compatible with your project. [C:\Project-UWP\Project.UWP\Project.UWP.wapproj]
"C:\Project-UWP\Project.UWP\Project.UWP.wapproj" (default target) (1) ->
"C:\Project\Project.csproj" (publish target) (2:9) ->
(ResolvePackageAssets target) ->
C:\Program Files\dotnet\sdk\5.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1047: Assets file 'C:\Project\obj\project.assets.json' doesn't have a target for 'net5.0-windows/win-x86'. Ensure that restore has run and that you have included 'net5.0-windows' in the TargetFrameworks for your project. You may also need to include 'win-x86' in your project's RuntimeIdentifiers. [C:\Project\Project.csproj]
2 Warning(s)
1 Error(s)
Time Elapsed 00:00:01.31
Notice that there are warnings related to framework references:
ProjectReference C:\Project\Project.csproj was resolved using .NETCoreApp,Version=v6.0 instead of the project target framework .NETFramework,Version=v4.5.1.
This project may not be fully compatible with your project. Microsoft.Common.CurrentVersion.targets 1719
The WPF project was set to use .NET 5, so I don't see why there's any reference to .NETCoreApp 6 or .NET Framework 4.5.1.
What have I tried? (Missing ARM64 issue)
I created a WAPP from scratch and saw that the option for ARM64 appeared in the architecture table.
But when publishing manually via the context menu, I'll get this error:
The specified RuntimeIdentifier 'win-ARM64' is not recognized.

Team Foundation Server Build errors....NuGet?

Im having build errors after building my Visual Studio Core repository from Team Foundation Server. My build order is Get Sources -> NuGet Restore, Build Solution, Publish Artifact
NuGet restore points to my NuGet.config file.
Looking at the error, it seems to me that my NuGet files are not being compiled. My Nuget files are pointing to a location in my file system. I can compile and run my program on VS but i cant successfully build using TFS.
Example errors:
project.assets.json not found, run a nuget restore to generate this file.
- After looking, I found the file in the same location it said not found?
The type or name space "System" could not be found
- Im getting this error for all 8 NuGet packages????
The NuGet.config can't be pointing to your file system if you expect the restore to work on a machine other than yours. It has to be pointing to a location that the build server can access.
I'd recommend setting up a Package Management feed containing your packages.

Visual Studio "Add REST API Client" not working

I am unable to use the Add... REST API Client... option in Visual Studio 2015 with all the latest updates and Azure Tools v2.9 installed. When I select the option I am presented with the proper dialog to provide either a url or the file path for the swagger json file. Regardless of which option I select I get the following error message:
Generating client code and adding to project started
Generate client code for REST API with following parameters:
REST API Name: ToDoListAPIClient, Base namespace: ToDoListAPI, Metadata file path: C:\Users\ken\AppData\Local\Temp\WebToolsAutoRest\ToDoListAPIClient\201702032141192827\swagger.json
Exception: Could not load file or assembly 'Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
Generating client code and adding to project failed
Adding REST API client for failed
How can I resolve this problem?
Make sure you download the proper version of the Newtonsoft.Json package by running the command:
PM> install-package Newtonsoft.Json -Version 7.0.1
Then copy the Newtonsoft.Json assembly (version 7.0.0.0) to C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE.
This should work around the issue.

The Dnx Runtime package needs to be installed - hosted Build Controller

I am developing my first ASP.NET 5 Application and I have some problems with hosted build on Visual Studio Team Services (was Visual Studio Online). I get the error:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(126,5): Error : The Dnx Runtime package needs to be installed.
One row before I see following Build message:
Cannot find DNX runtime dnx-clr-win-x86.1.0.0-beta8 in the folder: C:\Users\buildguest.dnx\runtimes
I found the solution with Prebuild-Powershell script (https://msdn.microsoft.com/Library/vs/alm/Build/azure/deploy-aspnet5)
Note: I added the ASP.Net 5 MVC Project to an existing solution. I have no global.json file and src folder! This is the reason why I have adapted the script as follows:
& iex((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))
$dnxVersion = "latest"
& $env:USERPROFILE\.dnx\bin\dnvm install $dnxVersion -Persistent
Get-ChildItem -Path $PSScriptRoot\..\InternalWeb.Client -Filter project.json -Recurse | ForEach-Object { & dnu restore $_.FullName 2>1 }
The script runs after Build step "Get sources" and has following output:
But, I get still the same error message! What's wrong?
Thanks for help!
Michael
I ran into the same problem and I found a solution that worked for me.
The PowerShell script installs the latest runtime or the one that you have specified in your global.json file. Since it did not work without a global.json file and the default settings, I added a global.json file to my project folder and specified the version that I am using:
{
"sdk": {
"version": "1.0.0-rc1-update1",
"runtime": "coreclr",
"architecture": "x86"
}
}
The first try failed again with the following error:
The expected lock file doesn't exist. Please run "dnu restore" to generate a new lock file.
So I added dnu restore to the end of the PowerShell script.
The next build was successful. May be this works for you too.

Resources