2016-08-22 93 views
3

我正在嘗試創建一個.Net Core Project,它是一個NETStandard.Library版本1.6.0。Asp .Net Core Project.json文件

我想試驗一個後期構建命令,但我現在注意到,在我們的project.json文件中,有一個可以創建的「後期編譯」腳本。

這裏是文檔。 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\" 

什麼我卡住了,是什麼變量現在可以在這裏給我,讓我訪問像構建outp ut目錄?我無法在任何地方找到對此的參考。

在此先感謝。

回答

4

完全上下文變量的列表,你可以用它來控制你的腳本流程是:

每個腳本塊:具體

%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

+0

謝謝你,這是一個非常有用的列表。我注意到,如果我的腳本直接在我的json文件中,我可以得到這些工作。但是,如果我將腳本放入.cmd文件中,它不再知道%compile:OutputDir%是什麼,並且我的腳本不再有效。任何線索如何讓他們在cmd文件中工作? –

+0

對不起。不知道那 – Sanket

+0

@ C.Moore你有沒有設法使用.cmd文件運行命令? – Sanket