BeforeBuild-AfterBuild目标未运行

时间:2015-09-15 01:31:57

标签: msbuild visual-studio-2015 asp.net-core

我最近开始将MVC项目从MVC5迁移到MVC6,一切正常,除了BeforeBuild / AfterBuild目标没有触发,我甚至在VS2015中打开VS 2013项目(.csproj)并运行,但是那些我在VS 2015中添加了新的.xproj文件。对可能发生的事情有任何想法吗?

谢谢!

project.json文件

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

2 个答案:

答案 0 :(得分:1)

ASP.NET 5不再使用csproj文件进行构建。它们仅供VS用于显示项目。一切都在project.json

您必须将这些目标迁移到project.json才能运行它们。这是一个例子:https://github.com/aspnet/dnx/blob/dev/src/Microsoft.Dnx.Project/project.json#L40-L47

答案 1 :(得分:0)

如果重新定义14.0版本工具的BuildDependsOn属性,它可以正常工作。这是VS目标使用的策略。

<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>