Cannot build Python.NET Python.Runtime in Visual Studio from master, or via setup.py - python.net

I tried to "Build Solution" from Visual Studio 2019, since the Python.NET project comes with a .sln VS Solution file
However, it skipped the Python.Runtime build which is what I'm interested in:
1>------ Skipped Build: Project: Python.Runtime ------
Furthermore, the other 4 builds had an error:
3>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\NuGet\16.0\Microsoft.NuGet.targets(186,5): error : Your project file doesn't list 'win-x64' as a "RuntimeIdentifier". You should add 'win-x64' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore.
Alternatively, when running python setup.py following instructions on https://github.com/pythonnet/pythonnet/wiki/Installation#github-installation-from-master-branch, I ran into another error from not being able to find Windows Kits installed roots. Have been looking around for answers and tried different versions of Python, .NET Core, .NET etc. to no avail. I detailed it in https://github.com/pythonnet/pythonnet/issues/1272
Environment
Pythonnet version: 3.0 (ongoing, latest master branch ending at c81c3c3)
Python version: 3.7.9
Operating System: Windows 10, 64bit, WinPE

I just loaded pythonnet.15.sln instead of pythonnet.sln and was able to build the DLL file.
Although I'm still not sure why pythonnet.sln didn't work for me, does "15" refer to the VS version? The regular sln was being used in this screenshot from a talk https://youtu.be/P7Or7XzeIno?t=1163

Related

Why can't I compile a .NET MAUI app on Visual Studio 2022?

I wanted to start coding something using .NET MAUI, so I updated my VS2022 to "Version 17.1.0 Preview 6.0".
Then I installed these features using "Visual Studio Installer" as suggested in https://learn.microsoft.com/en-us/dotnet/maui/get-started/installation
Unfortunately when I create a basic MAUI app, I get several errors like this:
Error NU1012 Platform version is not present for one or more target
frameworks, even though they have specified a platform: net6.0-android
On developer command line I tried running dotnet workload list and got
android
ios
maui-android
maui-maccatalyst
If I try to install some other workload (eg maui or maui-windows) I get an error stating
Unable to download manifest microsoft.net.workload.emscripten:
microsoft.net.workload.emscripten.manifest-6.0.200 has not been found
on NuGet feeds https://api.nuget.org/v3/index.json, C:\Program Files
(x86)\Microsoft SDKs\NuGetPackages"
I've also tried to completely remove and reinstall VS2022, without any luck.
I've then tried to run maui-check but when it tries to download Recommendation: Download .NET SDK (6.0.200) the exe is not valid and the task fails.
Worst part: I tried to install a fresh VS2022 preview on a different pc and everything works flawlessly... but I need it to work on my developmente pc!
.

Why does NuGet pack break with VS2019 build tools?

We have a number of .NET Framework projects with a "nuget pack MyProject.csproj" command in the post-build step. We have been using VS2010 (:O I know) until now, and it has been happily spitting out nupkg files.
We recently updated our build tools to the 2019 version (running the new version of varsall.bat before calling msbuild), and the "nuget pack" command now fails:
Error NU5012: Unable to find 'MyProject.dll'. Make sure the project has been built.
What I've tried:
Adding a "nuget spec" step before packing
Upgrading the nuget CLI executable to the latest version
Updating from packages.config to PackageReferences
This allows you to use MSBuild -t:pack. However, two issues:
When running this in the post-build step on my machine, it starts dozens of cmd & MSBuild processes and pegs my CPU.
Our developers are stuck on VS2017 for now, but the 2017 build tools are no longer available for our build server (so we use 2019). The 2017 & 2019 installs put MSBuild in different locations. We could set path variables for all the machines, but that seems brittle.
I'm playing with upgrading one of the projects to the new csproj format, but it is rather involved. Upgrading all of our projects will be an effort all its own, and I'm still exploring the ramifications.
Is there something simple I'm missing which will allow this to work without large modifications?
Error NU5012: Unable to find 'MyProject.dll'. Make sure the project
has been built.
This message indicates that the nuget.exe can't find the output assembly. So you must make sure the assembly is created successfully.
And one point you need to take care, normally we use command like nuget pack foo.csproj -Properties Configuration=Release to pack the assembly built in release mode. If you use command like nuget pack xx.csproj in post-build-event, no matter which configuration you use msbuild to build the project, nuget will always try to find the assembly in ProjectDir/bin/debug.
So when you deploy the project to remote server without bin and obj folders, if you try to use command like msbuild xx.csproj /p:Configuration=Release, the build is in release mode while nuget.exe will search the bin\debug instead of expected bin\release. You should check if you're in same situation.
Why does NuGet pack break with VS2019 build tools?
This issue is not about the build tools package. Since the error message you got came from nuget. Msbuild just help call the nuget.exe, and the cause of the issue is nuget.exe can't find the needed assembly by one specific path. Please check if the path in the error message is right, and then check if the assembly is in that path.
I also ran into the same issue during our TFS upgrade to Azure Devops. The new Nuget task doesn't have the switch for -Build. The fields in the Nuget task screen for Pack also doesn't allow you to add this switch, that's why it's complaining about not finding the dll or the output of the build. I modified the nugetpack.js file on the agent's task folder to test the theory and now the pack options build successfully.
This is the line I added to the js file (towards the bottom of the page):
nugetTool.arg("-Build");
what would be nice is to have this option represented as check box to cover if there is use case to call Nuget pack without -Build switch

MsBuild failing for .Net Standard project with error "Package System.Security.Cryptography.ProtectedData, version x.x.x was not found"

Project Setup : Mixed framework solution
.Net Framework 4.6.2 projects in solution : 15
.Net Standard 2.0 projects in solution - 1
Development Machine
Visual Studio 2017(15.7.4) : Builds without any errors
Build Server
TeamCity Version 2017.1.3
Build Steps
Nuget Restore(3.4.4)
dotnet Restore
MSBuild( Build Tools 2017), Tools Version 15.0
Build fails with following error in the .net standard 2.0 project : [ResolvePackageAssets] C:\Program Files\dotnet\sdk\2.1.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198, 5): Package System.Security.Cryptography.ProtectedData, version 4.4.0 was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions.
What's interesting is I can't find reference or use of System.Security.Cryptography.ProtectedData anywhere in the project. Any help is greatly appreciated.
P.S - Can't use dotnet build, as the solution needs building of licenses.licx files, and the component which builds it (Microsoft.Build.Tasks.LC) is not ported to .Net Core. The suggestion from various posts was to use MsBuild.exe

Cannot build .net core 1.1 with msbuild tools

I have a .net core class library I am attempting to build into a nugget package. however, on my build server (running team city), I am getting the following error:
C:\TeamCity\buildAgent\work\3c6531587491c25e\MySolution\MyProject.csproj
error MSB4019: The imported project "C:\Program Files (x86)\Microsoft
Visual
Studio\2017\BuildTools\MSBuild\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props"
was not found. Confirm that the path in the declaration is
correct, and that the file exists on disk.
When I look in this directory, I ma missing the "Microsoft.NET.Sdk" folder from my build server. where do I get these tools without having to install visual studio?
Thanks!
See the tracking issue on GitHub: https://github.com/Microsoft/msbuild/issues/1697
If you don't want to touch your build tools installation (by copying SDK files), you can also set the MSBuildSDKsPath environment variable to the location of the SDKs carried in the .net CLI (usually C:\Program Files\dotnet\sdk\1.0.0\Sdks\)

monodevelop won't compile VB code

I wanted to have a look at monodevelop, thinking about possible moving in-house projects written in .Net from Windows to Linux.
I installed mono-complete 4.0.2 and monodevelop 5.9.4 on a clean Ubuntu 14.04 VM, I assume those are the latest/current versions.
Now C# works, but I can't get it to compile any VB code.
Any new VB project I create first refuses to load.
Quickly found (Google) that the mono VB compiler doesn't support framework 4 or higher yet, but the project template generates projects targeted at 4.5.
After I manually edit the project file to target 3.5, 3.0 or 2.0, the projects load (this works for console as well as GTK projects).
But when I try to compile it then, no own code added yet, just the auto-generated base code, it just fails without any error messages.
Build output:
Building: VbHelloConsoleWorld (Debug|x86)
Build started 7/3/2015 10:42:20 AM.
__________________________________________________
Project "/home/luc/projects/VbHelloConsoleWorld/VbHelloConsoleWorld.vbproj" (Build target(s)):
Target PrepareForBuild:
Configuration: Debug Platform: x86
Target GenerateSatelliteAssemblies:
No input files were specified for target GenerateSatelliteAssemblies, skipping.
Done building project "/home/luc/projects/VbHelloConsoleWorld/VbHelloConsoleWorld.vbproj".-- FAILED
Build FAILED.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.0438100
---------------------- Done ----------------------
Build successful.
Am I still missing some dependencies? Other stuff that must be fixed before a VB project will work?
For some reason building VB.NET with MSBuild does not work.
To workaround this you can disable the use of the MSBuild build engine. Go into project options, Build - General and uncheck Use MSBuild build engine. Then the project should compile and generate an output assembly.