#Do a MS build of the nanoframework Project solution

1 messages · Page 1 of 1 (latest)

gloomy rampart
#

I have a complete nanoframework project folder I azure blob , I have take the zip file from blob do a MS build of the nanoframework project and again store the build files to the blob.

using Microsoft.Build.Evaluation;
using Microsoft.Build.Execution;
using Microsoft.Build.Framework;
using Microsoft.Build.Logging;

string projectFileName = @"C:\Users\Dell\source\repos\NFApp9\NFApp9.sln";

ProjectCollection pc = new ProjectCollection();

Dictionary<string, string> GlobalProperty = new Dictionary<string, string>();

GlobalProperty.Add("Configuration", "Debug");
GlobalProperty.Add("Platform", "x86");

BuildRequestData buildRequest = new BuildRequestData(projectFileName, GlobalProperty, null, new string[] { "Clean", "Rebuild" }, null);

BuildParameters buildParameters = new BuildParameters(pc)
{
Loggers = new[] { new ConsoleLogger(LoggerVerbosity.Normal) }
};

BuildResult buildResult = BuildManager.DefaultBuildManager.Build(buildParameters, buildRequest);

This is the code Iam trying out but i get the error:

agile ravine
steep marsh
#

Can you build that project with VS?

gloomy rampart
#

yes , I can

steep marsh
#

OK. So it's not project, it has to be whathever you're passing to msbuild. Make sure you're using msbuild and not dotnet command to do the build.

#

As a side comment: I don't recognize those errors above... don't recall ever seeing something similiar...

gloomy rampart
#

I tried building the solution with cmd dotnet build, i get the above error

#

but the same build get success when build normally

agile ravine
steep marsh
#

please read carefully the previous messages

gloomy rampart
#

Build FAILED.

"C:\Users\Dell\source\repos\Edge.Net\Program\Program.nfproj" (default target) (1) ->
"C:\Users\Dell\source\repos\Edge.Net\Common\Common.nfproj" (default target) (2:2) ->
(NanoGenerateBinaryOutput target) ->
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\nanoFramework\v1.0\NFProjectSystem.MDP.targets(779,5): error MSB4062: The "GenerateBinaryOutputTask" task could not be loaded from the assembly C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\nanoFramework\v1.0\nanoFramework.Tools.BuildTasks.dll. Could not load file or assembly 'file:///C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\nanoFramework\v1.0\nanoFramework.Tools.BuildTasks.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format. 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. [C:\Users\Dell\source\repos\Edge.Net\Common\Common.nfproj]

0 Warning(s)
1 Error(s)

Time Elapsed 00:00:00.97

gloomy rampart
#

Iam using MS build now

#

Iam getting this GenerateBinaryOutputTask, error as above

steep marsh
#

That has to do with the call not specifying the x64 build option. Please check our pipelines that are calling msbuild directly. IoT bindings is one of them.

lost epoch
agile ravine
lost epoch
#

I thought I am using Mono:

jakobhorauf@Air-von-Jakob Samples % nuget restore "/Users/jakobhorauf/Documents/Coding/DotNetTest/Samples/samples/Blinky/Blinky.sln" && msbuild "/Users/jakobhora
uf/Documents/Coding/DotNetTest/Samples/samples/Blinky/Blinky.sln" -p:NanoFrameworkProjectSystemPath=/Users/jakobhorauf/.vscode/extensions/nanoframework.vscode-na
noframework-1.0.140/dist/utils/nanoFramework/v1.0/
MSBuild auto-detection: using msbuild version '' from '/Library/Frameworks/Mono.framework/Versions/Current/Commands'.
Error parsing solution file at /Users/jakobhorauf/Documents/Coding/DotNetTest/Samples/samples/Blinky/Blinky.sln: Invalid Image
Invalid Image

It seems like it is not detecting the right (any) verison

agile ravine
#

I've been running this successfully on a M1. Tricky part is deploying with nanoff as there are driver issues with serial port. Exact same code and everything works fine on Windows in parallel using the same hardware. It drove me crazy!

lost epoch
#

So do you have any idea on what to do? Do you need more Information?

agile ravine
#

I would have to resetup properly the Mac to test. check out how it's done in the VS Code extension as it has all the needed elements

scarlet delta
#

I hope reviving an older thread is OK, because I ran into this issue as well.

In the VSCode plugin when you hit "Build", it runs this snippet of code:

$path = & "${env:ProgramFiles(x86)}\microsoft visual studio\installer\vswhere.exe" -products * -latest -prerelease -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe | select-object -first 1

c:\Users\Tim\.vscode\extensions\nanoframework.vscode-nanoframework-1.0.140/dist/utils/nuget/nuget.exe restore "c:/Users/Tim/Documents/repos/nanoworld/nanoworld.sln"

& $path "c:/Users/Tim/Documents/repos/nanoworld/nanoworld.sln" -p:NanoFrameworkProjectSystemPath=c:\Users\Tim\.vscode\extensions\nanoframework.vscode-nanoframework-1.0.140/dist/utils\nanoFramework\v1.0\

The first line finds MSBuild.exe and sets it to the $path variable, the second line restores nuget packages, and the third line compiles the solution. $path is defined in the first and used in the third.

This is using the 32 bit MSBuild.exe, and causes the GenerateBinaryOutputTask "invalid format" error mentioned above.

If you step through this manually but reference the amd64 version of MSBuild.exe, the build completes successfully.

& 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\amd64\MSBuild.exe' "c:\Users\Tim\Documents\repos\Blinky\Blinky\Blinky.sln" -p:NanoFrameworkProjectSystemPath=c:\Users\Tim\.vscode\extensions\nanoframework.vscode-nanoframework-1.0.140/dist/utils\nanoFramework\v1.0\

I'm still digging into the issue, but the problematic command line is defined in

.vscode\extensions\nanoframework.vscode-nanoframework-1.0.140\out\dotnet.js

So maybe it's an issue of bitness between VSCode, MSBuild, and nanoframework binaries since VSCode is 64 bit, The "found" MSBuild is 32 bit, and the nanoframework binaries are 64 bit.

agile ravine
#

stupid question: any reason to use the 32 bit version of MS Build? (I may have missed something somewhere)

scarlet delta
#

IMO, no since any Intel/AMD architecture machines are 64-bit, and Windows 10+ has been forced 64-bit for the last few years.

The "-find MSBuild**\Bin\MSBuild.exe" used to build the $path variable will only return 32 bit, though.

agile ravine
#

hum, I have all this as x64.

#

I4m using VS2022

scarlet delta
#

oh, this issue is in VSCode and the nanoframework VSCode extension. I figured I'd try that route first since VSCode is more "lightweight" than full VS.

I just finished installing VS2022 and the nanoframework extension for it.

agile ravine
#

the VS Code extensio requires quite some love indeed

scarlet delta
#

oh, this may be my chance to contribute. 🙂
I'll work on it a bit and see what it takes to get it up to speed and submit some pull requests if that's OK.