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": { }
}
}
Related
I got an error when I run test using Jest, I tried to fix this error for 2 hours. But, I couldn't fix it. My module is using gapi-script package and error is occurred in this package. However, I don't know why this is occurred and how to fix it.
jest.config.js
module.exports = {
"collectCoverage": true,
"rootDir": "./",
"testRegex": "__tests__/.+\\.test\\.js",
"transform": {
'^.+\\.js?$': "babel-jest"
},
"moduleFileExtensions": ["js"],
"moduleDirectories": [
"node_modules",
"lib"
]
}
babel.config.js
module.exports = {
presets: [
'#babel/preset-env',
]
};
methods.test.js
import methods, { typeToActions } from '../lib/methods';
methods.js
import { gapi } from "gapi-script";
...
Error Message
C:\haram\github\react-youtube-data-api\node_modules\gapi-script\index.js:1
({"Object.":function(module,exports,require,__dirname,__filename,global,jest){import
{ gapi, gapiComplete } from './gapiScript';
SyntaxError: Cannot use import statement outside a module
What is wrong with my setting?
As of this writing, Jest is in the process of providing support for ES6 modules. You can track the progress here:
https://jestjs.io/docs/en/ecmascript-modules
For now, you can eliminate this error by running this command:
node --experimental-vm-modules node_modules/.bin/jest
instead of simply:
jest
Be sure to check the link before using this solution.
I solved this with the help of Paulo Coghi's answer to another question -
Does Jest support ES6 import/export?
Step 1:
Add your test environment to .babelrc in the root of your project:
{
"env": {
"test": {
"plugins": ["#babel/plugin-transform-modules-commonjs"]
}
}
}
Step 2:
Install the ECMAScript 6 transform plugin:
npm install --save-dev #babel/plugin-transform-modules-commonjs
Jest needs babel to work with modules.
For the testing alone, you do not need jest.config.js, just name the testfiles xxx.spec.js or xxx.test.js or put the files in a folder named test.
I use this babel.config.js:
module.exports = function (api) {
api.cache(true)
const presets = [
"#babel/preset-env"
]
return {
presets
}
}
Adding "type": "module" in package.json or using mjs as stated in other answers is not necessary when your setup is not too complicated.
I have also faced the same issue and this was resolved by adding following command-line option as a environment variable.
export NODE_OPTIONS=--experimental-vm-modules npx jest //linux
setx NODE_OPTIONS "--experimental-vm-modules npx jest" //windows
Upgrading Jest (package.json) to version 29 (latest as of now) solved this problem for me.
Does Composer have any Command from CLI to add to composer.json such entry?
{
"autoload": {
"psr-4": {
"Monolog\\": "src/",
"Vendor\\Namespace\\": ""
}
}
}
and add this:
{
"autoload": {
"psr-0": {
"Monolog\\": "src/",
"Vendor\\Namespace\\": "src/",
"Vendor_Namespace_": "src/"
}
}
}
and this
{
"autoload": {
"classmap": ["src/", "lib/", "Something.php"]
}
}
and this:
{
"autoload": {
"files": ["src/MyLibrary/functions.php"]
}
}
I looked here:
Composer Command Line Documentation
but haven't found any dedicated command. Perhaps there is a workaround command like:
composer add-entry <key> <value>
or
composer set-key <key> <value>
but I don't know such,
do you know any?
Unfortunately NO. 😢 At least in v1.8.4 and I also want this feature too.
I thought the closest command would be config.
$ composer config bin-dir bin/
$ composer config repositories.github.com '{"type": "vcs", "url": "https://github.com/[YOUR]/[REPO]", "//url": "https://github.com/[YOUR]/[REPO].git"}'
Since this will add the following in composer.json:
"config": {
"bin-dir": "bin/"
},
"repositories": {
"github.com": {
"type": "vcs",
"url": "https://github.com/[YOUR]/[REPO]",
"//url": "https://github.com/[YOUR]/[REPO].git"
}
}
Though, this command seems to work only for "config" and "repositories" keys.
And then I found an issue about this topic. Seems that the community won't add this feature.😭
Yup I don't think we really want to offer this from CLI it's gonna be a bunch of code for very limited use as typically this is done once on package creation.
From: Issue #3398
"[Feature] Adding processing autoloading sections to the command line interface" # GitHub
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.
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?)
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.