【问题标题】:Asp .Net Core Project.json FileAsp .Net Core Project.json 文件
【发布时间】:2016-12-28 12:56:32
【问题描述】:

我正在尝试创建一个 .Net Core 项目,它是一个 NETStandard.Library 版本 1.6.0。

我想尝试使用 post build 命令,但现在我注意到在我们的 project.json 文件中,有一个可以创建的“postcompile”脚本。

这是文档。 https://docs.microsoft.com/en-us/dotnet/articles/core/tools/project-json

我创建了一个 .cmd 文件,我从 json 文件中调用它,如下所示:

"scripts": {
"postcompile": ["copyFiles.cmd"]

}

在我的 cmd 文件中,我可以有一个简单的复制命令,该命令有效:

xcopy /y "C:\Playground\test.txt" "C:\Playground\test\"

我坚持的是,现在我可以使用哪些变量来访问构建输出目录等内容?我在任何地方都找不到对此的参考。

提前致谢。

【问题讨论】:

    标签: json asp.net-core .net-core asp.net-core-1.0


    【解决方案1】:

    可用于在脚本中控制流程的上下文变量的完整列表是:

    每个脚本块:

    %project:Directory%
    %project:Name%
    %project:Version%
    

    具体编译:

    %compile:TargetFramework%
    %compile:FullTargetFramework%
    %compile:Configuration%
    %compile:OutputFile%
    %compile:OutputDir%
    %compile:ResponseFile%
    %compile:RuntimeOutputDir% (only available if there is runtime output)
    %compile:RuntimeIdentifier% (only availabe if there is runtime output)
    %comiple:CompilerExitCode% (only available in the postcompile script block)
    

    具体发布:

    %publish:ProjectPath%
    %publish:Configuration%
    %publish:OutputPath%
    %publish:TargetFramework%
    %publish:FullTargetFramework%
    %publish:Runtime%
    

    参考资料:

    https://github.com/aspnet/Home/wiki/Project.json-file#scripts

    Post build event depending on configuration name in new ASP.NET 5 project

    【讨论】:

    • 谢谢,这是一个非常有用的列表。我注意到如果我的脚本直接在我的 json 文件中,我可以让这些工作。但是,如果我将脚本放入 .cmd 文件中,它似乎不再知道 %compile:OutputDir% 是什么,并且我的脚本不再有效。任何线索如何让它们在 cmd 文件中工作?
    • 对不起.. 不知道
    • 不,不幸的是,我最终没有让 cmd 文件正常工作
    • @C.Moore 你可以通过命令行传递cmd所需的参数,例如myscript.cmd %compile:OutputDir%,并在脚本中使用$1,$2,...
    猜你喜欢
    • 2017-04-13
    • 1970-01-01
    • 1970-01-01
    • 2017-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-10
    • 2017-01-31
    相关资源
    最近更新 更多