1## Building LibSass with Visual Studio
2
3### Requirements:
4
5The minimum requirement to build LibSass with Visual Studio is "Visual Studio 2013 Express for Desktop".
6
7Additionally, it is recommended to have `git` installed and available in `PATH`, so to deduce the `libsass` version information. For instance, if GitHub for Windows (https://windows.github.com/) is installed, the `PATH` will have an entry resembling: `X:\Users\<YOUR_NAME>\AppData\Local\GitHub\PortableGit_<SOME_GUID>\cmd\` (where `X` is the drive letter of system drive). If `git` is not available, inquiring the LibSass version will result in `[NA]`.
8
9### Build Steps:
10
11#### From Visual Studio:
12
13On opening the `win\libsass.sln` solution and build (Ctrl+Shift+B) to build `libsass.dll`.
14
15To Build LibSass as a static Library, it is recommended to set an environment variable `LIBSASS_STATIC_LIB` before launching the project:
16
17```cmd
18cd path\to\libsass
19SET LIBSASS_STATIC_LIB=1
20::
21:: or in PowerShell:
22:: $env:LIBSASS_STATIC_LIB=1
23::
24win\libsass.sln
25```
26
27Visual Studio will form the filtered source tree as shown below:
28
29![image](https://cloud.githubusercontent.com/assets/3840695/9298985/aae9e072-44bf-11e5-89eb-e7995c098085.png)
30
31`Header Files` contains the .h and .hpp files, while `Source Files` covers `.c` and `.cpp`. The other used headers/sources will appear under `External Dependencies`.
32
33If there is a LibSass code file appearing under External Dependencies, it can be changed by altering the `win\libsass.vcxproj.filters` file or dragging in Solution Explorer.
34
35#### From Command Prompt:
36
37Notice that in the following commands:
38
39* If the platform is 32-bit Windows, replace `ProgramFiles(x86)` with `ProgramFiles`.
40* To build with Visual Studio 2015, replace `12.0` with `14.0` in the aforementioned command.
41
42Open a command prompt:
43
44To build dynamic/shared library (`libsass.dll`):
45
46```cmd
47:: debug build:
48"%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild" win\libsass.sln
49
50:: release build:
51"%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild" win\libsass.sln ^
52/p:Configuration=Release
53```
54
55To build static library (`libsass.lib`):
56
57```cmd
58:: debug build:
59"%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild" win\libsass.sln ^
60/p:LIBSASS_STATIC_LIB=1
61
62:: release build:
63"%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild" win\libsass.sln ^
64/p:LIBSASS_STATIC_LIB=1 /p:Configuration=Release
65```
66
67#### From PowerShell:
68
69To build dynamic/shared library (`libsass.dll`):
70
71```powershell
72# debug build:
73&"${env:ProgramFiles(x86)}\MSBuild\12.0\Bin\MSBuild" win\libsass.sln
74
75# release build:
76&"${env:ProgramFiles(x86)}\MSBuild\12.0\Bin\MSBuild" win\libsass.sln `
77/p:Configuration=Release
78```
79
80To build static library (`libsass.lib`):
81
82```powershell
83# build:
84&"${env:ProgramFiles(x86)}\MSBuild\12.0\Bin\MSBuild" win\libsass.sln `
85/p:LIBSASS_STATIC_LIB=1
86
87# release build:
88&"${env:ProgramFiles(x86)}\MSBuild\12.0\Bin\MSBuild" win\libsass.sln `
89/p:LIBSASS_STATIC_LIB=1 /p:Configuration=Release
90```
91