Carorus
Carorus

Reputation: 537

BeforeBuild-AfterBuild targets not running

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"
]
}

Upvotes: 1

Views: 1122

Answers (2)

Luís Ferreira
Luís Ferreira

Reputation: 1

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>  

Upvotes: 0

Victor Hurdugaci
Victor Hurdugaci

Reputation: 28425

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

Upvotes: 1

Related Questions