I made a new Class Library (Package) project in VS 2015 and added a reference to Microsoft.Owin package, however I can't access the Microsoft.Owin namespace.
This is my project.json file:
{
"version": "1.0.0-*",
"description": "Class1 Class Library",
"authors": [ "sebastiano.roncato" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"dependencies": {
"System.Collections": "4.0.10-beta-23019",
"System.Linq": "4.0.0-beta-23019",
"System.Threading": "4.0.10-beta-23019",
"System.Runtime": "4.0.10-beta-23019",
"Microsoft.CSharp": "4.0.0-beta-23019",
"Microsoft.Owin": "3.0.0",
"Owin": "1.0.0"
},
"frameworks": {
"dotnet": { }
}
}
Related
I am trying to create a library using parceljs and after npm run watch, i am getting
Uncaught ReferenceError: require is not defined
package.json
{
"name": "social-tagger",
"version": "1.0.0",
"description": "",
"source": "src/index.ts",
"main": "dist/main.js",
"module": "dist/module.js",
"scripts": {
"watch": "parcel watch",
"build": "parcel build"
},
"author": "",
"license": "ISC",
"dependencies": {
"#yaireo/tagify": "^4.12.0",
"jquery": "^3.6.0"
},
"devDependencies": {
"#parcel/packager-ts": "^2.6.2",
"#parcel/transformer-typescript-types": "^2.6.2",
"#types/jquery": "^3.5.14",
"parcel": "^2.6.2",
"typescript": "^4.7.4"
}
}
src/social.ts
import * as jQuery from 'jquery';
How to properly import jQuery
Output From Inspect Element
Added Targets to package.json
package.json
{
"name": "social-tagger",
"version": "1.0.0",
"description": "",
"source": "src/index.ts",
"main": "dist/main.js",
"module": "dist/module.js",
"scripts": {
"watch": "parcel watch",
"build": "parcel build"
},
"author": "",
"license": "ISC",
"dependencies": {
"#yaireo/tagify": "^4.12.0",
"jquery": "^3.6.0"
},
"devDependencies": {
"#parcel/packager-ts": "^2.6.2",
"#parcel/transformer-typescript-types": "^2.6.2",
"#types/jquery": "^3.5.14",
"parcel": "^2.6.2",
"typescript": "^4.7.4"
},
"targets":{
"main": {
"includeNodeModules": true
}
}
}
Create a file named jquery.ts
jquery.ts
import jquery from "jquery";
export default ((window as any).jQuery = jquery);
Dont import jquery instead import from jquery.ts
social.ts
import './jquery';
After we upgraded our web application to asp.net core 1.0 we're unable to get a successfull build within Appveyor.
There are several nuget packages issues, the first error is:
Microsoft.AspNetCore.Mvc 1.0.0 is not compatible with .NETCoreApp,Version=v1.0.
On of the feed that is used is https://www.nuget.org/api/v2 and we think it should use the V3 version to be able to build core 1.0 web projects.
Is our assumption correct and how do we force appveyor to use the v3 api instead v2?
How do we get a successful build for our asp.net core 1.0 project?
UPDATE
Our assumption seems not to be correct, with the command
nuget sources update -Name nuget.org -Source https://api.nuget.org/v3/index.json
the new v3 feed is successfully used but the build still fails with the same errors.
dotnet information from build-server:
.NET Command Line Tools (1.0.0-preview2-003121)
Product Information:
Version: 1.0.0-preview2-003121
Commit SHA-1 hash: removed
Runtime Environment:
OS Name: Windows
OS Version: 6.3.9600
OS Platform: Windows
RID: win81-x64
And our project.json:
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "default"
},
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0"
},
"tools": {
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.DotNet.Watcher.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.0": {}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true,
"compile": {
"exclude": [
"wwwroot",
"node_modules"
]
}
},
"runtimes": {
"win10-x64": {}
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
//"publishExclude": [
// "**.user",
// "**.vspscc"
//],
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
And global.json
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-003121"
}
}
Try updating nuget source during the build with this command:
nuget sources update -Name nuget.org -Source https://api.nuget.org/v3/index.json
I created a new Web Api project after installing the latest visual studio updates for TC 2.
Added entity Microsoft.EntityFrameworkCore": "1.0.0-rc2-final and Microsoft.EntityFrameworkCore.Tools: 1.0.0-preview1-final to the project.
Opened a command line and typed dotnet ef.
At this point I got an error:
Could not load file or assembly 'Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
Have I got the wrong tools version?
The version I used is what was available from intellisense.
Excerpt from project.json:
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-rc2-3002702",
"type": "platform"
},
"Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
"Microsoft.NETCore.Platforms": "1.0.1-rc2-24027",
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview1-final" ,
"type": "build"
}
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
},
"Microsoft.EntityFrameworkCore.Tools": {
"imports": [ "portable-net451+win8" ],
"version": "1.0.0-preview1-final"
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"dnxcore50",
"portable-net45+win8",
"portable-net451+win8"
]
}
},
A workaround that saved my day.
Delete:
%USERPROFILE%\.nuget\packages\.tools\Microsoft.EntityFrameworkCore.Tools
%USERPROFILE%\.nuget\packages\Microsoft.EntityFrameworkCore.Tools
Re-run dotnet restore
This appears to be known issue in RC2.
I will mark this as answered and wait for the EF team to sort it out.
I also had to add InternalAbstractions manually in the project.json file:
"Microsoft.DotNet.InternalAbstractions": "1.0.0",
https://github.com/dotnet/core/issues/366
In entity framework core 1.0 RC1 when I published a website, it generated a ef.cmd file, I can ran ef database update to update the product database. How can I do it in RC2 when there is no ef.cmd file.
With RC2, you need to install the tooling via your project.json file, then issue dotnet restore. Here is a sample project.json which also brings in EntityFrameworkCore.SQLite:
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0-rc2-3002702"
},
"Microsoft.EntityFrameworkCore.Tools": {
"type": "build",
"version": "1.0.0-preview1-final"
},
"Microsoft.EntityFrameworkCore.SQLite": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
},
"tools": {
"Microsoft.EntityFrameworkCore.Tools": {
"imports": ["portable-net451+win8"],
"version": "1.0.0-preview1-final"
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": "portable-net451+win8"
}
}
}
The important parts here are:
"Microsoft.EntityFrameworkCore.Tools": {
"type": "build",
"version": "1.0.0-preview1-final"
}
And
"tools": {
"Microsoft.EntityFrameworkCore.Tools": {
"imports": ["portable-net451+win8"],
"version": "1.0.0-preview1-final"
}
},
These tell the dotnet restore command to download the tooling for entity framework. Now you'll be able to use the .NET Core CLI Entity Framework functionality.
This will let you do things like:
$ dotnet ef migrations add myMigration
$ dotnet ef database update
I'm using Typescript, React, and Webpack and struggling to import the keymirror module.
I am using the latest version of typescript.
package.json
{
"name": "Fun",
"version": "1.0.0",
"description": "Dear Webpack Gods, please help.",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "",
"dependencies": {
"eventemitter3": "^1.1.1",
"flux": "^2.0.3",
"keymirror": "^0.1.1",
"react": "^0.13.3",
"ts-loader": "^0.5.0",
"typescript": "^1.6.0-dev.20150812"
},
"devDependencies": {
"css-loader": "^0.16.0",
"style-loader": "^0.12.3"
}
}
webpack.config.js
module.exports = {
entry: './App/app.tsx',
output: {
filename: 'bundle.js'
},
resolve: {
extensions: ['', '.js', '.tsx', '.ts']
},
module: {
loaders: [
{ test: /\.ts(x?)$/, loader: 'ts-loader' },
{ test: /\.css$/, loader: 'style-loader!css-loader' }
]
}
}
tsconfig.json
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"jsx": "react",
"sourceMap": true
},
"files": [
"./typings/tsd.d.ts",
"./App/app.tsx"
]
}
The offending import is located in ./User/Constants.ts
import keyMirror = require('keymirror');
export = keyMirror({
LOGIN_ATTEMPT: null
});
I have tried using the standalone npm module as seen above, as well as attempting to require it from react/lib/keyMirror.
Any ideas?
(EDIT: Yes, I know it's a 12 line module that I could just copy into my code.)
Solution from Basarat (with slight modification)
declare module 'keymirror' {
function keyMirror(obj: Object);
export = keyMirror;
}
import keyMirror = require('keymirror');
You need to tell typescript about it. Basically something like :
declare module 'keymirror' {
var export:any;
export = export;
}
In a file called global.d.ts.
Some docs : http://basarat.gitbooks.io/typescript/content/docs/types/ambient/intro.html