2017-12-13 16 views
0

.lessファイルを実行時にコンパイルしようとしています。しかしdotlessライブラリでは@import file.lessファイルが見つかりません。.reslessで終わるファイルが見つかりません。

私のすべてのファイルは、メインlessファイルと同じディレクトリにあります。

これは私のC#のコードです:

var config = new DotlessConfiguration() { 
     MinifyOutput = true, 
     ImportAllFilesAsLess = true 
    }; 
    string css = Less.Parse(less,config); 

私が変換しようとしています主な以下のファイル:

@import "font-awesome.less"; 
@fa-font-path: "/fonts"; 

@sco_green: #63b02e; 
@sco_orange: #f18500; 

@blue-deep:#00a2d1; 

@white: #ffffff; 
@active: #ffcb8b; 
@gray: #999; 
@gray-dark: #525252; 
@gray-middle: #b8bcba; 
@gray-light: #dbdbdb; 
@gray-lighter: #efefef; 
@gray-super-light: #f7f7f7; 
@gray20:#333; 
@gray94:#F0F0F0; 

のWeb設定:

<configSections> 
    <section name="dotless" type="dotless.Core.configuration.DotlessConfigurationSectionHandler, dotless.Core" /> 
</configSections> 

<system.web> 
    <httpHandlers> 
     <add path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler, dotless.Core" /> 
    </httpHandlers> 
</system.web> 
<system.webServer> 
    <validation validateIntegratedModeConfiguration="false" /> 
    <handlers> 
     <add name="dotless" path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler,dotless.Core" resourceType="File" preCondition="" /> 
    </handlers> 

</system.webServer> 
<dotless minifyCss="true" cache="true" web="false" disableParameters="true" /> 

エラーメッセージ:

enter image description here

どうすれば動作させることができますか?

+0

それ以外の場合は、実際のコードを推測してください。 – Valkyrie

+0

.lessファイルの内容を追加しました。その他のコードは何を提供すべきですか? – JustLearning

答えて

1

Googleでほぼすべての単一の検索結果を経由した後、私は基本的に私は、ファイルを@import見つけることができるようにdotlessの現在の作業ディレクトリを設定する必要が this:

が見つかりました:

私が持っていたので、すべてのC#で行うには:

string filePath = $"{_filePath}\\main.less"; 
    string less = ReadFile(filePath); 
    var dotlessConfig = new dotless.Core.configuration.DotlessConfiguration(); 
    Directory.SetCurrentDirectory(_filePath); 
    string css = Less.Parse(less,dotlessConfig); 
関連する問題