How can I target .NET35 on OSX using mono and dnx/dnvm? - unity3d

on Windows using Visual Studio 2015, I can compile a project with dnu build.
The project.json file looks as follows:
{
"version": "1.0.0-*",
"description": "My Class Library",
"authors": [ "Class Library template" ],
"tags": [""],
"projectUrl": "",
"licenseUrl": "",
"tooling": {
"defaultNamespace": "Common"
},
"frameworks": {
"dnx451": { },
"dnxcore50": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-*",
"System.Collections": "4.0.11-beta-*",
"System.Linq": "4.0.1-beta-*",
"System.Runtime": "4.0.21-beta-*",
"System.Threading": "4.0.11-beta-*"
}
}
}
}
After installing mono, dnvm and dnx on a Mac, as per this tutorial, I can actually compile the same project on OSX! This in itself is already pretty awesome!
now, I added the following framework to my project.json file:
"frameworks": {
"dnx35": { }, //"net35"
"dnx451": { },
"dnxcore50": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-*",
"System.Collections": "4.0.11-beta-*",
"System.Linq": "4.0.1-beta-*",
"System.Runtime": "4.0.21-beta-*",
"System.Threading": "4.0.11-beta-*"
}
}
This still compiles on Windows, and produces three sets of dlls, as expected.
However, on OSX it does not build the dnx20 target. Though as far as I understand, the mono compiler mcs can be set to target .net35 by passing in a sdk parameter.
So my question is: Can I target .NET35 with dnx on OSX using mono?
EDIT
The goal of this question is to compile a set of dll's that can be imported into Unity3d. And because Unity3d uses mono as a runtime, I would like to be able to do that by using dnu build, as to be able to develop these dll's on any platform.

You can pass custom Rosyln compiler options via compilationOptions in the project.json file:
"compilationOptions": {
"optimize": true,
"define": ["RELEASE", "TRACE", "PLAYSCRIPT"]
},
Take a look at the various project.json files in the Github aspnet/dnx project, i.e. project.json
But those options are being passed to Rosyln not mcs, Mono is being used as a CLR host for Rosyln's compiler as a service), but I do not believe you are substitute Mono's mcs for that (comments on this anyone?)

Related

CI Using Azure Pipelines and Nx fails

UPDATE: I was able to get this working by setting "ProduceReferenceAssembly" to false in the .csproj files of the libs. Not sure if this is optimal or intended but that is what worked for me. See: Ref folder within .NET 5.0 bin folder
I'm trying to set up a proof of concept using NX dot net and Azure using this exaple .yml: https://nx.dev/recipes/ci/monorepo-ci-azure
I have 3 services (libs) and 3 apis (apps) ... I made a change to one of the apis to test caching and incremental builds.
The unchanged projects all say [remote cache] but then the build fails because it's looking for the .dlls in the /obj/Debug/ directory. Why use that when there are .dlls in the /dist directory?
How can I fix this? Is there something in the nx.json or project.json files I need to change?
(https://i.stack.imgur.com/IQhaO.png)
I tried using the same command locally on my machine and it completes as expected. I expect the build to complete. The build fails when remote caching is used.
{
"name": "ShipmentService",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"sourceRoot": "libs/ShipmentService",
"targets": {
"build": {
"executor": "#nx-dotnet/core:build",
"outputs": [
"{workspaceRoot}/dist/libs/ShipmentService",
"{workspaceRoot}/libs/ShipmentService/obj"
],
"options": {
"configuration": "Debug",
"noDependencies": true
},
"configurations": {
"production": {
"configuration": "Release"
}
}
},
"lint": {
"executor": "#nx-dotnet/core:format"
}
},
"tags": []
}
Tried proposed workaround, here's what I'm noticing: platformservice:build [remote cache]
Error, it sees the intermediates part, but basically same issue: same error
Updated project.json (all of them have been updated to look similar to this [tried with and without /obj portion]):
"outputs": [
"{workspaceRoot}/dist/libs/ShipmentService",
"{workspaceRoot}/dist/intermediates/libs/ShipmentService/obj"
],
This is a bug on nx-dotnet's side, and we aren't quite capturing all of the outputs that are needed for the cache. If you add the path to the obj directory into the outputs array of the build target in project.json it should work. Here's the workaround which will eventually be migrated:
I've got a branch with this working, you do indeed need the obj directory as part of the cache. There are some weird intricacies with this though. I'll work on a migration + patch. In the meantime, the workaround that I used is:
Update Directory.Build.props adding these to the property group containing the output path manipulation:
<BaseIntermediateOutputPath>$(RepoRoot)dist/intermediates/$(ProjectRelativePath)/obj</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)</IntermediateOutputPath>
As an example, the full file looks like this on the nx-dotnet repo now:
<Project>
<PropertyGroup>
<!-- Output path configuration -->
<RepoRoot>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)'))</RepoRoot>
<ProjectRelativePath>$([MSBuild]::MakeRelative($(RepoRoot), $(MSBuildProjectDirectory)))</ProjectRelativePath>
<BaseOutputPath>$(RepoRoot)dist/$(ProjectRelativePath)</BaseOutputPath>
<OutputPath>$(BaseOutputPath)</OutputPath>
<BaseIntermediateOutputPath>$(RepoRoot)dist/intermediates/$(ProjectRelativePath)/obj</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)</IntermediateOutputPath>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<PropertyGroup>
<RestorePackagesWithLockFile>false</RestorePackagesWithLockFile>
</PropertyGroup>
</Project>
Your project.json file should look something like this now:
{
"name": "demo-webapi",
"sourceRoot": "demo/apps/webapi",
"targets": {
"build": {
"executor": "#nx-dotnet/core:build",
"outputs": [
"{workspaceRoot}/dist/demo/apps/webapi",
"{workspaceRoot}/dist/intermediates/demo/apps/webapi"
],
"options": {
"configuration": "Debug",
"noDependencies": true
},
"configurations": {
"production": {
"configuration": "Release"
}
}
}
}
}

TYPO3 CMS 8.7.27: Call to a member function getPackagePath() on null

After installing extensions in typo3 CMS 8.7.27, I got following error.. Seems like the ExtensionManagementUtility can't load the ah_contentapi.
This is my composer.json file in root (/var/www/html/typo3) for loading my extensions:
{
"repositories":[
{
"type":"composer",
"url":"https://composer.typo3.org/"
},
{
"type":"package",
"package":{
"name":"Bm/ah-content-api",
"version":"0.0.1",
"type":"typo3-cms-extension",
"source":{
"url":"https://user#bitbucket.org/company/ah_config_typo3.git",
"type":"git",
"reference":"master"
}
}
},
{
"type":"package",
"package":{
"name":"Bm/ah-contentelements",
"version":"0.0.1",
"type":"typo3-cms-extension",
"source":{
"url":"https://user#bitbucket.org/company/ah_contentelements_typo3.git",
"type":"git",
"reference":"master"
}
}
}
],
"name":"typo3/cms-base-distribution",
"description":"TYPO3 CMS Base Distribution",
"license":"GPL-2.0-or-later",
"require":{
"helhum/typo3-console":"^4.9.3 || ^5.2",
"typo3/cms-about":"^8.7.10",
"typo3/cms-belog":"^8.7.10",
"typo3/cms-beuser":"^8.7.10",
"typo3/cms-context-help":"^8.7.10",
"typo3/cms-documentation":"^8.7.10",
"typo3/cms-felogin":"^8.7.10",
"typo3/cms-fluid-styled-content":"^8.7.10",
"typo3/cms-form":"^8.7.10",
"typo3/cms-func":"^8.7.10",
"typo3/cms-impexp":"^8.7.10",
"typo3/cms-info":"^8.7.10",
"typo3/cms-info-pagetsconfig":"^8.7.10",
"typo3/cms-rte-ckeditor":"^8.7.10",
"typo3/cms-setup":"^8.7.10",
"typo3/cms-sys-note":"^8.7.10",
"typo3/cms-t3editor":"^8.7.10",
"typo3/cms-tstemplate":"^8.7.10",
"typo3/cms-viewpage":"^8.7.10",
"typo3/cms-wizard-crpages":"^8.7.10",
"typo3/cms-wizard-sortpages":"^8.7.10",
"typo3/cms":"^8.7",
"dmitryd/typo3-realurl":"2.*",
"GridElementsTeam/Gridelements":"8.2.*",
"clickstorm/cs_seo":"3.*",
"Bm/ah-content-api":"0.0.1",
"Bm/ah-contentelements":"0.0.1"
},
"scripts":{
"typo3-cms-scripts":[
"typo3cms install:fixfolderstructure",
"typo3cms install:generatepackagestates"
],
"post-autoload-dump":[
"#typo3-cms-scripts"
]
},
"extra":{
"typo3/cms":{
"web-dir":"public"
},
"helhum/typo3-console":{
"comment":"This option is not needed ay more for helhum/typo3-console 5.x",
"install-extension-dummy":false
}
},
"autoload":{
"psr-4":{
"Bm\\AhContentelements\\":"public/typo3conf/ext/ah_contentelements/Classes",
"Bm\\AhContentapi\\":"public/typo3conf/ext/ah_content_api/Classes"
}
}
}
I already cleared cache in install tool at:
1. -> important actions -> clear all cache
2. -> clean up -> Clean typo3temp/ folder
piece from composer.lock:
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is #generated automatically"
],
"content-hash": "954afd2318d54ec9b1dd0e4d7f9b445b",
"packages": [
{
"name": "Bm/ah-content-api",
"version": "0.0.1",
"source": {
"type": "git",
"url": "https://stevenhippovibe#bitbucket.org/hippovibe/ah_config_typo3.git",
"reference": "master"
},
"type": "typo3-cms-extension"
},
{
"name": "Bm/ah-contentelements",
"version": "0.0.1",
"source": {
"type": "git",
"url": "https://stevenhippovibe#bitbucket.org/stevenhippovibe/ah_contentelements_typo3.git",
"reference": "master"
},
"type": "typo3-cms-extension"
},
The Error occurs when the extension folder name under typo3conf/ext/<folder_name> doesn't match extension key used in some places of the system (e.g. using EXT:your_extension_key/... syntax in TypoScript).
Changing folder name fixed similar problem for me.
Check the PHP version and try to change it from i.e. 7.4 to 7.3.
I once had this problem with an extension that should be compatible with PHP 7.4, but wasn't in real life. This solved the problem for me.
Question here is:
How did you update to 8.7.27 (which composer command was executed)
How does your composer.lock look like?
Do you use TYPO3 console or any other special composer plugins / CLI commands to e.g. generate PackageStates.php?
I just ran into the same error message under TYPO3 9.5.5.
Solution:
Deinstall one TYPO3 extension after the other and try it out again. This will lead you to the extension which has an error. Most probably the error is inside of the file ext_localconf.php or ext_tables.php .
I got this error detail:
PHP Warning: Use of undefined constant FH_DEBUG_EXT - assumed 'FH_DEBUG_EXT' (this will throw an Error in a future version of PHP) in /var/www/html/global-extensions/ext/div2007/ext_localconf.php line 15
This has nothing to do with your error. But it can be that you have an error in one of your installed extensions or even in a backup of an extension, e.g. a folder named as extensionname.bak .
Also these recommendations can help:
https://wiki.typo3.org/Exception/CMS/1476107295

MissingMethodException on connect with Npgsql + Dotnet CLI on CentOs 7.1

I'm running Dotnet CLI version 1.0.0-rc2-002439 on CentOS 7.1
I've built a prototype Console application that just performs a select against a PostgreSQL 9.4 database.
I'm only targeting DNXCORE50 and on windows, everything works just fine. When I'm running it on CentOS I get the following exception on conn.Open()
Unhandled Exception: System.MissingMethodException: Method not found: 'Void System.Net.Security.SslStream.AuthenticateAsClient(System.String, System.Security.Cryptography.X509Certificates.X509CertificateCollection, System.Security.Authentication.SslProtocols, Boolean)'.
at Npgsql.NpgsqlConnector.RawOpen(NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnector.Open()
at Npgsql.NpgsqlConnectorPool.GetPooledConnector(NpgsqlConnection Connection)
at Npgsql.NpgsqlConnectorPool.RequestConnector(NpgsqlConnection connection)
at Npgsql.NpgsqlConnection.OpenInternal(NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnection.Open()
at SensorBot.Core.Services.ConfigService.GetConfig()
at ConsoleApplication.Program.Main(String[] args)
Here is the project.json I'm using :
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": false
},
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-rc2-23811"
},
},
"runtimes": { "centos.7-x64": { } },
"frameworks": {
"dnxcore50": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Collections": "4.0.11-beta-23516",
"System.Console": "4.0.0-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Threading": "4.0.11-beta-23516",
"System.IO": "4.1.0-*",
"System.IO.FileSystem": "4.0.1-rc2-23811",
"System.Runtime.Serialization.Primitives": "4.1.1-*",
"System.Dynamic.Runtime": "4.0.11-*",
"System.Net.Security": "4.0.0-beta-23405",
"System.Net.NetworkInformation": "4.1.0-beta-23405",
"System.Text.RegularExpressions": "4.0.12-rc2-23811",
"Npgsql": "3.1.0-alpha6"
}
}
}
}
I have seen on the npgsql's Github that using https://www.myget.org/gallery/npgsql-unstable as a package source and using the unstable version of Npgsql fixes it but when I use "Npgsql": "3.1.0-unstable0458" the app doesn't compile and says that this version of npgsql is not compatible with DNXCore 5.0.
There must be something I'm doing wrong because other people don't seem to have issues with this any more.
Any ideas ?
I've had the same exception with npgsql version 3.1.0-alpha6
Unhandled Exception: System.MissingMethodException: Method not found: 'Void System.Net.Security.SslStream.AuthenticateAsClient(System.String, System.Security.Cryptography.X509Certificates.X509CertificateCollection, System.Security.Authentication.SslProtocols, Boolean)'.
However I was able to succeed with both versions: 3.1.0-unstable0458 and 3.1.0-unstable0478.
Currently I'm using Centos 7.2, Dotnet CLI version 1.0.0-rc2-002510. As a test application I've created a simple console app with one select to postgresql.
project.json looks like this:
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0-rc2-23811"
},
"Npgsql": "3.1.0-unstable0478"
},
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50",
}
}
}
Because I use SSL connection to db I had to add few options to my connection string: SSL Mode=Require;Trust Server Certificate=True;Use SSL Stream=True.
Maybe you should try to use a newer version of dotnet cli. If you have any questions about my os/dotnet environment, please let me know.

Syntax to specify latest pre-release in nuget 3.2rc

I'm trying to configure my project.json file to always download the latest pre-release version of the Roslyn Nightly pacakages.
{
"dependencies": {
"Microsoft.CodeAnalysis.Common": "1.1.0-beta"
},
"frameworks": {
"net452": { }
}
}
This gets me the following version:
WARNING: Dependency specified was Microsoft.CodeAnalysis.Common (≥ 1.1.0-beta) but ended up with Microsoft.CodeAnalysis.Common 1.1.0-beta1-20150812-01.
This is not the newest, which is advertised as:
v1.1.0-beta1-20150906-01
Any suggestions on the correct syntax in the project.json to always get the latest even if it's pre-release? Or is this a bug.
(Source for Roslyn nightly is: https://www.myget.org/gallery/roslyn-nightly)
The following works:
{
"dependencies": {
"Microsoft.CodeAnalysis.Common": "1.1.0-beta1-*"
},
"frameworks": {
"net452": { }
}
}

VSCode - adding c# assembly reference

Getting the following error:
The name 'File' does not exist in the current context[dnxcore50]
Tried to build it in-case it was to do with VSCode alone. It threw me same error.
I have installed the dependency using the following:
dnu install System.IO
Gave me the following message
c:\Users\user1\Dropbox\dev\csharp\vscode\ads\WeightedGraphs>dnu
install System.IO
GET https://www.nuget.org/api/v2/FindPackagesById()?Id='System.IO'.
OK https://www.nuget.org/api/v2/FindPackagesById()?Id='System.IO' 679ms
System.IO.4.0.10-beta-22816 was added to project.json.
Restoring packages for c:\Users\user1\Dropbox\dev\csharp\vscode\ads\WeightedGraphs\project.json
Writing lock file c:\Users\user1\Dropbox\dev\csharp\vscode\ads\WeightedGraphs\project.lock.json
Restore complete, 302ms elapsed
project.json
{
"version": "1.0.0-*",
"dependencies": {
"System.IO": "4.0.10-beta-22816"
},
"commands": {
"run": "run"
},
"frameworks": {
"dnx451": {},
"dnxcore50": {
"dependencies": {
"System.Collections": "4.0.10-beta-22816",
"System.Linq": "4.0.0-beta-22816",
"System.Console": "4.0.0-beta-22816"
}
}
}
}
In.cs
using System.IO;
public class In{
public In(string s){
var filename = s;
var path = "";
if(File.Exists(path)){
//Code TO Be Added
}
}
}
You also need to add "System.IO.FileSystem" to your dependencies.