The Dnx Runtime package needs to be installed - hosted Build Controller - asp.net-core-mvc

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.

Related

Error while running MSBuild.SonarQube.Runner against C# project

I’m trying to use MSBuild SonarQube scanner for my C# project. RootFolder has a .sln file, and each project (.csproj) is created in a separate folder inside the root folder. I've the project property file in RootFolder.
SonarQube server (LTS version 6.7.5) is up fine.
My Current env details:
Visual Studio 2010
.Net Framework 4.5.2
MSBuild version 4
sonarScanner for MSBuild 4.3.1.1372
Sonar Csharp Plugin version : 7.3.2.6129
When I’m trying to run below ‘begin’ command from project root directory, I see this error:
M:\myProjectCsharp>MSBuild.SonarQube.Runner.exe begin /k:”myProjectCsharp”/n: “myProjectCsharp”/v:”1.0”
Unhandled Exception: System.MissingMethodException: Method not found: '!!0[] System.Array.Empty()'.
at SonarScanner.MSBuild.Program.Execute(String[] args, Boolean showDeprecatedWarning)
at MSBuild.SonarQube.Runner.Program.Main(String[] args)
I guess it has something to do with compatibility of .Net Framework or MSBuild version ?
Also, what's the role of visual studio here, I already got.sln, .csproject and their corresponding .cs files in respective project directory under RootFolder 'myProjectCsharp'
(I don’t see any error if I simply run the sonar-scanner-msbuild-4.3.1.1372-net46\sonar-scanner-3.2.0.1227\bin\sonar-scanner but this doesn’t seems to update anything on dashboard (Just show 0 Bugs,Vulnerabilities & code smells) )
Any clue please ?
Thanks.

VS2017 MSB4057 The target "CreateManifestResourceNames" does not exist in the project

When VS2017 was used to create a stateful solution, producing the standard boilerplate code, the resulting two projects have two different MSBuild versions.
The application uses MSBuild version 1.5.0.
The service uses MSBuild version 1.6.0 (the current "latest").
If I run the solution this way, it runs fine on my local Service Fabric cluster.
But when after I use NuGet to update the application's MSBuild to 1.6.0 (so both application and server projects use the same), the following errors occur.
Severity Code Description Project File Line Suppression State
Error The OutputPath property is not set for project 'gt_strd5.sfproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' P follow a project-to-project reference to this project, this project has belatform='x64'. This error may also appear if some other project is trying toen unloaded or is not included in the solution, and the referencing project does not build using the same or an equivalent Configuration or Platform. gt_strd5 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets 737
Severity Code Description Project File Line Suppression State
Error MSB4057 The target "CreateManifestResourceNames" does not exist in the project. gt_strd5 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets 2630
I found that after the change, some references in the application's project file continued to reference MSBuild 1.5.0. In my case, the gt_strd5.sfproj file contained four references which needed to be updated from 1.5.0 to 1.6.0. See the snippets from the XML below.
Import Project="..\packages\Microsoft.VisualStudio.Azure.Fabric.**MSBuild.1.5.0**\build\Microsoft.VisualStudio.Azure.Fabric.Application.props" Condition="Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.**MSBuild.1.5.0**\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')"
.....
Import Project="..\packages\Microsoft.VisualStudio.Azure.Fabric.**MSBuild.1.5.0**\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets" Condition="Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.**MSBuild.1.5.0**\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')"
To verify this, I went back a couple times and was able to reproduce both the issue and this solution.
Hope it saves someone else some time.
Best Regards
I was getting this error into PCF control.
Run Developer Command Prompt VS2017/ VS2019
a) Remove white space from your folder like Test%20-%20PCFs (source control generated name) should be TestPCFs
b) Go to pcf project folder from cmd line & run msbuild /t:restore
b) Go to cds project folder from cmd line & run msbuild /t:restore
c) On cds project folder, run msbuild
d) For release deployment run msbuild /p:configuration=Release
For other types of projects
a) Remove white space from your folder name
b) run msbuild /t:restore
c) run msbuild

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

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 }

Could not write destination file: Access to path 'd:\a\src\...\Web.config' is denied

I have a tfs project on visual studio online and created a build definition to compile this project. The project uses web config transformation. The build will be executed from the visual studio online hosted build controller and it fails because of the following error:
Could not write destination file: Access to path 'd:\a\src...\Web.config' is denied.
Any ideas how to resolve this issue?
Sounds like the classic problem of read-only files (see cannot modify .csproj files using build auto with tfs 13). Run a pre-build Powershell script that removes the attribute, something like this
Get-ChildItem -Include *.config -Recurse | foreach {
if ($_.IsReadOnly) { $_.IsReadOnly = $false }
}

Entity Framework with NuGet - Import-Module error in init.ps1

Here is the complete error message that I get in the Package Manager Console when starting VS2010:
Import-Module : The specified module
'C:\Users\adam.assman\Project\packages\EntityFramework.4.3.1\tools\EntityFramework.psd1'
was not loaded because no valid module file was found in any module
directory. At
C:\Users\adam.assman\Project\packages\EntityFramework.4.3.1\tools\init.ps1:13
char:14
I've installed Entity Framework using NuGet, on a DLL/ClassLibrary project in my solution. The startup project is referencing and using this DLL project. I therefore tried running the startup command from the console with the DLL project selected in the dropdown "Default Project", but that gives me the same error message.
I have NuGet version 1.6.21215.9133 (and obviously EF version 4.3.1).
If I try to run the command "Enable-Migrations -EnableAutomaticMigrations", I get a CommandNotFoundException and I suppose it's a result from the init error. I'm trying to accomplish the simplest form of the automatic migrations, using this guide: http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-automatic-migrations-walkthrough.aspx
I have no idea what was wrong, but I finally fixed this by editing the file init.ps1 inside the folder \packages\EntityFramework.4.3.1\tools.
I changed this line:
Import-Module (Join-Path $toolsPath 'EntityFramework.psd1') -ArgumentList $installPath
Into this:
Import-Module '.\packages\EntityFramework.4.3.1\tools\EntityFramework.psd1' -ArgumentList $installPath

Resources