I recently started migrating a MVC project from MVC5 to MVC6, everything works fine, except that the BeforeBuild/AfterBuild targets are not firing, I even opened the VS 2013 project (.csproj) in VS2015 and they run, but the ones I added to the new .xproj file in VS 2015 don't. Any idea on what could be happening?
Thanks!
project.json file
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta6-*",
"Microsoft.AspNet.Authentication.OpenIdConnect": "1.0.0-beta6-*",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta6-*",
"Microsoft.AspNet.Mvc": "6.0.0-beta6-*",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta6-*",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta6-*",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta6-*",
"Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta5-*",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta6-*",
"Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta6-*",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta6-*",
"Microsoft.Framework.Logging": "1.0.0-beta6-*",
"Microsoft.Framework.Logging.Console": "1.0.0-beta6-*"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini"
},
"frameworks": {
"dnx451": {
"dependencies": {
"Microsoft.Framework.Configuration.Json": "1.0.0-beta6",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta6"
}
}
},
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
],
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
]
}
ASP.NET 5 doesn't use the csproj files anymore for build. They are only used by VS to display the project. Everything is in project.json.
You have to migrate those targets to project.json in order for them to run. Here's an example: https://github.com/aspnet/dnx/blob/dev/src/Microsoft.Dnx.Project/project.json#L40-L47
If you redefine the BuildDependsOn property for a 14.0 version tooling, it works fine. This is the strategy used by the VS targets.
<Target Name="CopyAutomapper">
<ItemGroup>
<MySourceFiles Include="$(SolutionDir)\packages\AutoMapper\5.1.1\lib\net45\AutoMapper.dll"/>
</ItemGroup>
<Copy
SourceFiles="#(MySourceFiles)"
DestinationFolder="$(OutputPath)\$(Configuration)\net461\win7-x64"
/>
</Target>
<PropertyGroup>
<BuildDependsOn>
$(BuildDependsOn);
CopyAutomapper;
</BuildDependsOn>
</PropertyGroup>
Related
I'm currently facing an ugly Problem while trying to scaffold from Control class.
I get the following error:
The error text is:
There was an error running the selected Code Generator: 'Unhandled
Exception: System.TypeLoadException: Could not load typa
'Microsoft.VisualStudio.Web.CodeGeneration.ConsoleLogger' from
assembly Microsoft.VisualStudio.Web.CodeGeneration.Core,
Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. at
Microsoft.VisualStudio.Web.CodeGeneration.Tools.Program.Main(String []
args)'
My project.json file is:
"Microsoft.EntityFrameworkCore.Design": "1.1.2",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.2",
"Microsoft.EntityFrameworkCore.SqlServer.Design": {
"version": "1.1.1",
"type": "build"
},
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.2",
"Microsoft.Extensions.Configuration.Json": "1.1.2",
"Microsoft.Extensions.Configuration.UserSecrets": "1.1.1",
"Microsoft.Extensions.Logging": "1.1.2",
"Microsoft.Extensions.Logging.Console": "1.1.2",
"Microsoft.Extensions.Logging.Debug": "1.1.1",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.2",
"Microsoft.NETCore.App": {
"version": "1.1.1",
"type": "platform"
},
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.1.0-preview4-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGeneration.Core": "1.1.1",
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": "1.1.1",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGeneration.Design": "1.0.1"
"tools": {
"BundlerMinifier.Core": "2.4.337",
"Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final",
"Microsoft.Extensions.SecretManager.Tools": "1.1.0-preview4-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.1.0-preview4-final",
"imports": [
"portable-net45+win8"
]
}
},
Any idea where I'm doing wrong?
I've already read some other Posts on SO, but I've found no help.
I decided to move to Visual Studio 2017. After some troubles I got it running again, but be aware:
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.0-msbuild3-final" PrivateAssets="All" />
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0-msbuild3-final" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0-msbuild3-final" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0-msbuild3-final" />
</ItemGroup>
I hope this will help
I am new to ASP.NET and I am trying to publish a web app. I have tried with 2 different hosts to do a web deploy but keep receving the error:-
No executable found matching command "dotnet-bundle"
What is this related to?
Project.Json
{
"dependencies": {
"Bitly.Net": "0.0.6",
"BitlyAPI": "1.0.3",
"BundlerMinifier.Core": "2.2.281",
"Common.Logging": "3.4.0-Beta2",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Routing": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"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",
"Parse": "1.7.0",
"Spring.Social.Twitter": "2.0.0-M1",
"Stormpath.AspNetCore": "0.7.0"
},
"tools": {
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"net46": {
"frameworkAssemblies": {
}
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"publishOptions": {
"include": [
"wwwroot",
"**/*.cshtml",
"appsettings.json",
"web.config"
]
},
"scripts": {
"prepublish": [ "bower install", "dotnet bundle" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
},
"userSecretsId": "aspnet-ParseAppDashboard-20161008081***"
}
In tools section of Project.json add this-
"tools": {
"BundlerMinifier.Core": "2.2.281",
....
On saving Project.json, VS2015 automatically restore packages.
If it doesn't worked then right click on project and click on Restore Packages option.
If this doesn't worked then try restoring using dotnet restore CLI command.
See if this helps.
Since the end of 2016 (RC3 & later, VS2017 & later) move to .csproj file format, add
<DotNetCliToolReference Include="BundlerMinifier.Core" Version="2.6.375" />
to an <ItemGroup>:
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
...
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0-msbuild3-final" />
<DotNetCliToolReference Include="BundlerMinifier.Core" Version="2.6.375" />
</ItemGroup>
</Project>
Or create a new <ItemGroup> (you can have many of them) for your DotNetCliToolReference settings.
But look at https://www.nuget.org/packages/BundlerMinifier.Core for the latest version number
You probably also need to add
"runtimes": {
"win10-x64": {}
},
to your project.json if you want to upgrate to core 1.1 (also change to correct runtime in the global.json file) I say this because I got the bundle error after upgrading my packages and app to 1.1 in VS2015.
I got the error
Failed to resolve the following dependencies for target framework
'DNX,Version=v4.5.1': framework/fx/System.configuration 4.0.0.0
When I run a docker container. But it works fine in IIS.
The project file is
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Diagnostics": "1.0.0-beta6",
"Microsoft.AspNet.Mvc": "6.0.0-beta6",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta6",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta6",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta6",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta6",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-beta6",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta6",
"Microsoft.Framework.Logging": "1.0.0-beta6",
"Microsoft.Framework.Logging.Console": "1.0.0-beta6",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta6",
"EntityFramework": "6.1.3",
"jqGridWebApi": "1.1.4",
"EnyimMemcached": "2.13.0",
"xunit": "2.2.0-beta1-build3239",
"Moq": "4.2.1510.2205",
"NLog": "2.1.0",
"CryptSharpOfficial": "2.1.0",
"System.Linq.Dynamic": "1.0.4"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5001",
"kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5005"
},
"frameworks": {
"dnx451": {
"frameworkAssemblies": {
"System.configuration": "4.0.0.0",
"System.Data": "4.0.0.0"
}
}
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
],
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
},
"configurations": {
"Staging": { }
}
}
My global.json file is
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-beta6"
}
}
And
So why?
Beta 6 is no longer supported. Upgrading to RC1 should resolve the issue.
I'm stuck with very simple problem.
I want to load local .NET 4 class library (dll) project to be used as resource in my new ASP.NET Web API project (first time trying asp.net)
I'm familiar with Winforms apps and now trying to create a ASP.NET Web API to be able to access one of my helper DLL from PHP/linux server. I'm not sure if this is a good approach, but I'm trying to prevent from re-implementing the logic of the DLL in PHP code.
The problem now is that I'm not able to add the DLL or the library class project to the resources of the Web API project.
While trying to solve the problem i have tried:
Visual Studio 2015 new project->ASP.NET web application->ASP.NET Core 1.0
templates->Web API
Create new Class Library project to the Web API solution (or import existing project)
Add the project to Web API project references
Add using directive of class library namespace to controller
Try to build and it gets error:
Error CS0246 The type or namespace name 'ClassLibrary1' could not be found (are you missing a using directive or an assembly reference?) WebApplication1.DNX Core 5.0
For me it it seems that it's trying to fetch the resource from nuget or something.
I hope some one can easily point me my mistake so I can continue to work with the actual work. (Or am I just miss using the Web API concept?)
project.json
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.ApplicationInsights.AspNet": "1.0.0-rc1",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
},
"frameworks": {
"dnx451": {
"dependencies": {
"ClassLibraryTest2": "1.0.0-*"
}
},
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
No need to remove the dnxcore50 part.
Just remove "ClassLibraryTest2": "1.0.0-*" from dnx451 and add the dependency in the list of global dependencies. It will apply it on dnx451 and dnxcore50.
The project.json would look like this:
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.ApplicationInsights.AspNet": "1.0.0-rc1",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
"ClassLibraryTest2": "1.0.0-*"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
},
"frameworks": {
"dnx451": {
"dependencies": {
}
},
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
I'm having an issue with DescriptionAttribute in ASP.NET 5 project.
I wanted to use DescriptionAttribute for my enum class, but the project cannot be built due to missing reference in DNX Core 5.0
Here's my project.json file
{
"userSecretsId": "",
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
"Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnx451": {
"frameworkAssemblies": {
}
},
"dnxcore50": {
"frameworkAssemblies": {
},
"dependencies": {
}
}
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
],
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
}
}
System.ComponentModel.DescriptionAttribute is not available in CoreCLR.
You have two options:
Find a replacement for it or implement it yourself.
Remove dnxcore50 (CoreCLR) from your supported framework list in project.json