PostSharp support on M1 Macs (linux-arm64) - arm64

I've recently started using PostSharp for caching on a .NET 5 app and it's working phenomenally on my 2015 MacBook Pro (Intel). However, I just recently got an M1 Mac Mini, which has Apple's own M1 chipset (linux-arm64), and, unfortunately, I am not able to build the solution anymore. The error I'm getting is:
#19 8.572 /root/.nuget/packages/postsharp/6.9.8/build/PostSharp.targets(381,5): error : This version of PostSharp does not support linux-arm64 runtime. [/src/Infrastructure/Infrastructure.csproj]
#19 8.586
#19 8.586 Build FAILED.
#19 8.586
#19 8.586 /root/.nuget/packages/postsharp/6.9.8/build/PostSharp.targets(381,5): error : This version of PostSharp does not support linux-arm64 runtime. [/src/Infrastructure/Infrastructure.csproj]
#19 8.586 0 Warning(s)
#19 8.586 1 Error(s)
#19 8.586
#19 8.586 Time Elapsed 00:00:08.05
------
failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c dotnet build -c Release -o /app]: exit code: 1
My current project file indicates the following dependencies:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Application\Application.csproj" />
</ItemGroup>
<ItemGroup>
...
<PackageReference Include="PostSharp" Version="6.9.8" />
<PackageReference Include="PostSharp.Patterns.Caching" Version="6.9.8" />
<PackageReference Include="PostSharp.Patterns.Caching.Redis" Version="6.9.8" />
...
</ItemGroup>
</Project>
It looks like there isn't a linux-arm64 build for PostSharp on Nuget. They do indicate support for macOS 10.14 in their docs here, but not anything about support for M1 Macs.
Is there a way to get a linux-arm64 build of PostSharp (even if I have to build from source myself)?

Related

Xamarin.Shared.Sdk.targets(366,3) MessagingRemoteException, AggregateException and NotImplementedException

I am running this command
dotnet publish -f:net6.0-ios -c:Release
to build a .NET MAUI App and create the .ipa file for iOS (.csproj at the end)
and I get this error:
C:\Program
Files\dotnet\packs\Microsoft.iOS.Sdk\15.4.303\targets\ Xamarin.Shared.Sdk.targets(366,3) :
error : MessagingRemoteException: An error occurred on client Build
while executing a reply for topic xvs/build/execute-task/OnesieMobile/
18e8f3c002fMergeAppBundles
[C:\Development_BuildPipeline\OnesieMobile\OnesieMobile\OnesieMobile.csproj]
C:\Program
Files\dotnet\packs\Microsoft.iOS.Sdk\15.4.303\targets\ Xamarin.Shared.Sdk.targets(366,3) :
error : AggregateException: One or more errors occurred. (The method
or operation is not implemented.) [C:\Development_BuildPipeline\Ones
ieMobile\OnesieMobile\OnesieMobile.csproj]
C:\Program
Files\dotnet\packs\Microsoft.iOS.Sdk\15.4.303\targets\ Xamarin.Shared.Sdk.targets(366,3) :
error : NotImplementedException: The method or operation is not
implemented.
[C:\Development_BuildPipeline\OnesieMobile\OnesieMobile\Ones
ieMobile.csproj]
C:\Program
Files\dotnet\packs\Microsoft.iOS.Sdk\15.4.303\targets\Xamarin.Shared.Sdk.targets(366,3):
error : [C:\Develo
pment_BuildPipeline\OnesieMobile\OnesieMobile\OnesieMobile.csproj]
I was able to successfully do the whole process of publishing an app all the way to my IPhone with the demo .NET MAUI application that comes with the template in Visual Studio 2022.
I was also able to clone and publish this project https://github.com/jfversluis/dotnet-maui-workshop/tree/main/Part%202%20-%20MVVM all the way to my IPhone.
So I thought I start working on my own project.
It works great when I press the play button in Visual Studio and run it as Windows App on my Windows in the debugger
It also works great on the remote iOS simulator in the cloud Mac through Visual Studio on my machine. (Although it takes 15 Minutes to fire it up!)
Environment:
Windows 10 Home, 21H2
VS 2022 Version 17.3.0 Preview 1.1
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>OnesieMobile</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Display name -->
<ApplicationTitle>OnesieMobile</ApplicationTitle>
<!-- App Identifier -->
<ApplicationId>com.maui.app</ApplicationId>
<ApplicationIdGuid>447A62C6-2841-41D6-B9AE-444E6E1A908B</ApplicationIdGuid>
<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
<RuntimeIdentifiers>ios-arm64</RuntimeIdentifiers>
<CodesignProvision>Maui Provisioning</CodesignProvision>
<CodesignKey>Apple Distribution: My Name (XXXX)</CodesignKey>
<ArchiveOnBuild>true</ArchiveOnBuild>
<TcpPort>58181</TcpPort>
<ServerAddress>xxxxx</ServerAddress>
<ServerUser>xxxx</ServerUser>
<ServerPassword>xxxx</ServerPassword>
<_DotNetRootRemoteDirectory>/Users/xxxx/Library/Caches/Xamarin/XMA/SDKs/dotnet/</_DotNetRootRemoteDirectory>
</PropertyGroup>
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="1.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="7.1.2" />
<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
</ItemGroup>
<ItemGroup>
<Compile Update="View\ActivityDetailPage.xaml.cs">
<DependentUpon>ActivityDetailPage.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<MauiXaml Update="View\ActivityDetailPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="View\SettingsPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>
</Project>
Figured it out.
I had to change
<RuntimeIdentifiers>ios-arm64</RuntimeIdentifiers>
to
<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
then it worked.
The official documentation gives the singular version https://learn.microsoft.com/en-us/dotnet/maui/ios/deployment/overview
The reason why I had changed it, was because of this
Errors with dotnet publish
but then later I also went through this
error NETSDK1032: The RuntimeIdentifier platform 'ios-arm64' and the PlatformTarget 'x64' must be compatible, which was probably the original reason why the plural form worked. In the *.csproj.user file the value was set to this
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
and since for some reason the project settings and the command line arguments are overruled by the *.csproj.user file, the only property that would do something was the one in the plural form.
Unfortunately I can not tell anymore after all these errors, if I actually had a version that would publish with the plural settings. (I believe I did)
In short:
I followed the documentation
it was "probably" the *.csproj.user that messed up my configurations
which then messed up the inputs I was thinking I was entering
which then lead me to the latest error, which is also not a proper error I would say, since it does not describe in any way the probable cause.
To summarize, deleting the .csproj.user and setting the .csproj to something like the following should work. And then execute
dotnet publish -f:net6.0-ios -c:Release
.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>OnesieMobile</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Display name -->
<ApplicationTitle>OnesieMobile</ApplicationTitle>
<!-- App Identifier -->
<ApplicationId>com.maui.app</ApplicationId>
<ApplicationIdGuid>447A62C6-2841-41D6-B9AE-444E6E1A908B</ApplicationIdGuid>
<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
<CodesignProvision>Maui Provisioning</CodesignProvision>
<CodesignKey>Apple Distribution: My Name (XXXX)</CodesignKey>
<ArchiveOnBuild>true</ArchiveOnBuild>
<TcpPort>58181</TcpPort>
<ServerAddress>xxxxx</ServerAddress>
<ServerUser>xxxx</ServerUser>
<ServerPassword>xxxx</ServerPassword>
<_DotNetRootRemoteDirectory>/Users/xxxx/Library/Caches/Xamarin/XMA/SDKs/dotnet/</_DotNetRootRemoteDirectory>
</PropertyGroup>
</Project>
Explanation
Try checking your Maui environment by installing MAUI check.
MAUI Check is a tool that determines if your environment is ready for MAUI development. While you could go about installing MAUI using the dot net CLI exclusively, the tool makes sure you have all the appropriate workloads available to build towards a target environment and more. It will also install any necessary templates for MAUI apps.
STEP 1
Open your command prompt window.run the following command from your terminal:
dotnet tool install -g Redth.Net.Maui.Check
STEP 2
Once you have MAUI Check installed, run the following command from your terminal:
maui-check
The process will install the following dependencies into your environment:
OpenJDK – For building Android, Android SDK and Emulator and .NET SDK Workloads for MAUI (Android, macOS, MacCatalyst, iOS, and tvOS)
STEP 3
Finally, in this step, let’s end with one more workload install of WASM tools. You need this workload because MAUI supports hosting Blazor inside a MAUI app.
Run the following command from your terminal:
dotnet workload install wasm-tools
Note:
In case, you already have installed the environmental dependencies of Xcode, OpenJDK, and Android SDK yourself, you can run the following command in a terminal to install the necessary workloads. Run the following command from your terminal:
I hope this will help.

How do I specify a target architecture when building projects in Visual Studio code?

I am new to VS code/F# and I am trying to build a F# console app (on both Windows workstation and on my Linux computer).
I installed the Ionide extension together with FAKE.
The code I am considering is the Iris example (see How to translate the intro ML.Net demo to F#?), creating a New F# Project with Ionide and using Microsoft.ML.
My iris.fsproj is
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net461</TargetFramework>
<DebugType>portable</DebugType>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Compile Include="iris.fs" />
<None Include="App.config" />
</ItemGroup>
<Import Project="..\.paket\Paket.Restore.targets" />
</Project>
When running the script (which I do with the "play" button aka F#: run script provided with VS Code/Ionide) I get:
C:\Users\MyUser\.nuget\packages\microsoft.ml\0.2.0\build\Microsoft.ML.targets(16,5): error : Microsoft.ML currently supports 'x64' processor architectures. Please ensure your application is targeting 'x64'.
together with
Running build failed.
Error:
System.Exception: dotnet build failed
How do I target x64 with the project structure provided by Ionide?
It should be as simple as adding the following line to your PropertyGroup section:
<PlatformTarget>x64</PlatformTarget>
There are more complicated setups possible using the Condition attribute to set the platform target based on various command-line arguments to the compiler, but that should be the simplest way to get you up and running.

Why does this dotnet test run crash only in a Docker container?

I have this .NET Core 1.1 solution including an ASP.NET Core project and an NUnit test project. Each of projects has the necessary properties (I can show more if necessary).
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
</PropertyGroup>
I can restore, build, and run the test suite locally (Windows 10) without any problems.
$ dotnet restore
Restoring packages for...
Restore completed in...
Generating MSBuild file...
$ dotnet build
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Example -> ...
Test -> ...
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed ...
$ cd test/
$ dotnet test
Build started, please wait...
Build completed.
Test run for ...
Microsoft (R) Test Execution Command Line Tool Version 15.3.0-preview-20170628-02
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
NUnit Adapter 3.8.0.0: Test execution started
Running all tests in ...
NUnit3TestExecutor converted 11 of 11 NUnit test cases
Total tests: 11. Passed: 11. Failed: 0. Skipped: 0.
Test Run Succeeded.
Test execution time: ...
The test suite uses NUnit 3 and I'm on all the latest stable versions. Here are the interesting package refs.
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.3" />
<PackageReference Include="FluentAssertions" Version="4.19.3" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="1.1.3" />
<PackageReference Include="NUnit" Version="3.8.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
However, when I run the tests from a .NET Core SDK Docker image/container, they fail dramatically!
The active test run was aborted. Reason: Unable to communicate with test host process.
Here's the simple Dockerfile
FROM microsoft/dotnet:1.1-sdk
WORKDIR /app
COPY . .
The restore and build work find, but the test aborts!
$ docker image build --tag example:latest .
...
$ docker container run --rm -it example:latest
root#abcdef12345:/app# dotnet restore
...
root#abcdef12345:/app# dotnet build
...
root#abcdef12345:/app# cd test/
root#abcdef12345:/app# dotnet test
...
Microsoft (R) Test Execution Command Line Tool Version 15.0.0.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
NUnit Adapter 3.8.0.0: Test execution started
Running all tests in ...
NUnit3TestExecutor converted 11 of 11 NUnit test cases
The active test run was aborted. Reason: Unable to communicate with test host process.
Searches for this error message get me nowhere. I'm not sure how to debug a test run abort. Higher levels of verbosity do not print anything useful. Let me know what I can try to get more information, eliminate possibilities, and provide more useful info!

TFS Build fails after successful test run

I am trying to set up a build definition on tfs for .NET core which includes a test step with XUnit. Everything works fine until my tests pass, and then for some reason, the build fails immediately after.
Total tests: 2. Passed: 2. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 3.3499 Seconds
Error: d:\a\_tool\dncs\2.0.0\x64\dotnet.exe failed with return code: 1
Dotnet command failed with non-zero exit code on the following projects :
That's it, no other detail. I am confused where to go from here, the test step is currently the last one in the build definition.
EDIT
This is the verbose output obtained by setting debug = true
2017-10-19T09:50:00.4882598Z ##[debug]rc:1
2017-10-19T09:50:00.4902607Z ##[debug]success:false
2017-10-19T09:50:00.5002614Z ##[error]Error:
d:\a\_tool\dncs\2.0.0\x64\dotnet.exe failed with return code: 1
2017-10-19T09:50:00.5002614Z ##[debug]Processed: ##vso[task.issue
type=error;]Error: d:\a\_tool\dncs\2.0.0\x64\dotnet.exe failed with return
code: 1
2017-10-19T09:50:00.5022599Z ##[debug]task result: Failed
2017-10-19T09:50:00.5032599Z ##[error]Dotnet command failed with non-zero
exit code on the following projects :
2017-10-19T09:50:00.5032599Z ##[debug]Processed: ##vso[task.issue
type=error;]Dotnet command failed with non-zero exit code on the following
projects :
2017-10-19T09:50:00.5042604Z ##[debug]Processed: ##vso[task.complete
result=Failed;]Dotnet command failed with non-zero exit code on the
following projects :
Try following bellow items:
Open the project file (eg *.csproj) comment out below snippet:
<DotNetCliToolReference Include="BundlerMinifier.Core" Version="X.X.XXX" />
Create a new build definition with ASP.NET Core (.NET Framework)
template used.
Also reference this thread : VSTS build: Packages failed to restore - Unable to resolve 'NETStandard.Library (>= 1.6.1)' for '.NETStandard,Version=v2.0'
So I fixed the issue by modifying the csproj file in the test project and adding a cli tool reference like so
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170628-02" />
<PackageReference Include="Moq" Version="4.7.142" />
<PackageReference Include="MSTest.TestAdapter" Version="1.1.18" />
<PackageReference Include="MSTest.TestFramework" Version="1.1.18" />
<PackageReference Include="xunit" Version="2.3.0" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta2-build3683" /> <-- This bit here!!!
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0" />
</ItemGroup>
In the build process on TFS, I removed the Dotnet test step and added in its place a command line step and configured it as I did below. Everything works now and the build is successful.

NuGet Package missing error when trying to use TFS Servcice

I'm hoping someone can help diagnose whats going wrong with my build. I'm using Visual Studio 2012, NuGet 2.7, & TFS Service (git). I've been unable to get around the following error:
"C:\a\src\src\RecipeDb.Mvc\RecipeDb.Mvc.csproj (361): 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=317567."
I've enabled the package restore feature (but it think i've heard with nuget 2.7 it doesn't matter). Anyways i found a helpful blog about this problem at :
Blog Article
Here is my current build script:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0"
DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutDir>$(MSBuildThisFileDirectory)bin</OutDir>
<Configuration>Release</Configuration>
<ProjectProperties>
OutDir=$(OutDir);
Configuration=$(Configuration);
</ProjectProperties>
</PropertyGroup>
<ItemGroup>
<Solution Include="$(MSBuildThisFileDirectory)src\*.sln" />
</ItemGroup>
<Target Name="RestorePackages">
<Exec Command=""$(MSBuildThisFileDirectory)src\.nuget\NuGet.exe" restore "%(Solution.Identity)"" />
</Target>
<Target Name="Clean">
<MSBuild Targets="Clean"
Projects="#(Solution)"
Properties="$(ProjectProperties)" />
</Target>
<Target Name="Build" DependsOnTargets="RestorePackages">
<MSBuild Targets="Build"
Projects="#(Solution)"
Properties="$(ProjectProperties)" />
</Target>
<Target Name="Rebuild" DependsOnTargets="RestorePackages">
<MSBuild Targets="Rebuild"
Projects="#(Solution)"
Properties="$(ProjectProperties)" />
</Target>
</Project>
and here is my build log:
Build started 9/27/2013 1:01:14 AM.
Project "C:\a\src\build.proj" on node 1 (default targets).
RestorePackages:
"C:\a\src\src\.nuget\NuGet.exe" restore "C:\a\src\src\RecipeDb.sln"
Project "C:\a\src\build.proj" (1) is building "C:\a\src\src\RecipeDb.sln" (2) on node 1 (Build target(s)).
ValidateSolutionConfiguration:
Building solution configuration "Release|Any CPU".
Project "C:\a\src\src\RecipeDb.sln" (2) is building "C:\a\src\src\RecipeDb.Mvc\RecipeDb.Mvc.csproj" (3) on node 1 (default targets).
C:\a\src\src\RecipeDb.Mvc\RecipeDb.Mvc.csproj(361,5): error : 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=317567.
Done Building Project "C:\a\src\src\RecipeDb.Mvc\RecipeDb.Mvc.csproj" (default targets) -- FAILED.
Project "C:\a\src\src\RecipeDb.sln" (2) is building "C:\a\src\src\RecipeDb.Mvc.Tests\RecipeDb.Mvc.Tests.csproj" (5) on node 1 (default targets).
C:\a\src\src\RecipeDb.Mvc.Tests\RecipeDb.Mvc.Tests.csproj(144,5): error : 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=317567.
Done Building Project "C:\a\src\src\RecipeDb.Mvc.Tests\RecipeDb.Mvc.Tests.csproj" (default targets) -- FAILED.
Done Building Project "C:\a\src\src\RecipeDb.sln" (Build target(s)) -- FAILED.
Done Building Project "C:\a\src\build.proj" (default targets) -- FAILED.
Build FAILED.
"C:\a\src\build.proj" (default target) (1) ->
"C:\a\src\src\RecipeDb.sln" (Build target) (2) ->
"C:\a\src\src\RecipeDb.Mvc\RecipeDb.Mvc.csproj" (default target) (3) ->
(EnsureBclBuildImported target) ->
C:\a\src\src\RecipeDb.M
vc\RecipeDb.Mvc.csproj(361,5): error : 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=317567.
"C:\a\src\build.proj" (default target) (1) ->
"C:\a\src\src\RecipeDb.sln" (Build target) (2) ->
"C:\a\src\src\RecipeDb.Mvc.Tests\RecipeDb.Mvc.Tests.csproj" (default target) (5) ->
C:\a\src\src\RecipeDb.Mvc.Tests\RecipeDb.Mvc.Tests.csproj(144,5): error : 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=317567.
0 Warning(s)
2 Error(s)
Time Elapsed 00:00:09.21
So i copied his build log and just changed the path where nuget.exe is. Nuget.exe command seems to be running but apparently its not downloading the packages. Of course building locally works fine (even if i delete the packages directory.
As I can see in the link in the error message line you posted:
There is an improvement in Nuget 2.7 as below:
The Improvement
We’ve updated Microsoft.Bcl.Build to use a different approach. The
new version will use a conditional import similar to what NuGet’s
automatic import feature does. This will always allow the project to
load in Visual Studio.
However, Microsoft.Bcl.Build also adds a target to your project
that will run after the build is finished. This target checks whether
the current build restored packages and if so fail the build with an
actionable error message:
The build restored NuGet packages. Build the project again to include
these packages in the build. For more information, see
http://go.microsoft.com/fwlink/?LinkID=317568.
Building a second time will fix this error. Please note that this
error will only appear if packages were missing so it’s not like you
always have to build twice.
However, below that it says that it will not address build server/continuous integration (CI) scenarios and it needs a solution as specified in the following excerpt from the article:
This solution doesn’t address build server / continuous integration
(CI) scenarios. In order to successfully use package restore on the
build server, you have two options:
Check-in the .targets file.
Explicitly run NuGet package restore prior to building your project/solution.
Hope the issue you are facing is also because of this only.
For me the reference to Microsoft.Bcl.Build and the BeforeTargets="BeforeBuild" was causing problems. This got added when Microsoft.Bcl.Build was added as a dependency to an Azure Nuget package.
Try checking your project file and removing it.
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="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=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target>

Resources