fix windows build

This commit is contained in:
Andrew Stanton-Nurse 2015-10-31 21:19:15 -07:00
parent d5412f767e
commit fbedf48da2
4 changed files with 28 additions and 52 deletions

View file

@ -8,25 +8,22 @@ Build Status
|**Debug**|[![Build Status](http://dotnet-ci.cloudapp.net/buildStatus/icon?job=Private/dotnet_cli_debug_ubuntu)](http://dotnet-ci.cloudapp.net/job/Private/job/dotnet_cli_debug_ubuntu/)|[![Build Status](http://dotnet-ci.cloudapp.net/buildStatus/icon?job=Private/dotnet_cli_debug_windows_nt)](http://dotnet-ci.cloudapp.net/job/Private/job/dotnet_cli_debug_windows_nt/)|[![Build Status](http://dotnet-ci.cloudapp.net/buildStatus/icon?job=Private/dotnet_cli_debug_osx)](http://dotnet-ci.cloudapp.net/job/Private/job/dotnet_cli_debug_osx/) | |**Debug**|[![Build Status](http://dotnet-ci.cloudapp.net/buildStatus/icon?job=Private/dotnet_cli_debug_ubuntu)](http://dotnet-ci.cloudapp.net/job/Private/job/dotnet_cli_debug_ubuntu/)|[![Build Status](http://dotnet-ci.cloudapp.net/buildStatus/icon?job=Private/dotnet_cli_debug_windows_nt)](http://dotnet-ci.cloudapp.net/job/Private/job/dotnet_cli_debug_windows_nt/)|[![Build Status](http://dotnet-ci.cloudapp.net/buildStatus/icon?job=Private/dotnet_cli_debug_osx)](http://dotnet-ci.cloudapp.net/job/Private/job/dotnet_cli_debug_osx/) |
|**Release**|[![Build Status](http://dotnet-ci.cloudapp.net/buildStatus/icon?job=Private/dotnet_cli_release_ubuntu)](http://dotnet-ci.cloudapp.net/job/Private/job/dotnet_cli_release_ubuntu/)|[![Build Status](http://dotnet-ci.cloudapp.net/buildStatus/icon?job=Private/dotnet_cli_release_windows_nt)](http://dotnet-ci.cloudapp.net/job/Private/job/dotnet_cli_release_windows_nt/)|[![Build Status](http://dotnet-ci.cloudapp.net/buildStatus/icon?job=Private/dotnet_cli_release_osx)](http://dotnet-ci.cloudapp.net/job/Private/job/dotnet_cli_release_osx/) | |**Release**|[![Build Status](http://dotnet-ci.cloudapp.net/buildStatus/icon?job=Private/dotnet_cli_release_ubuntu)](http://dotnet-ci.cloudapp.net/job/Private/job/dotnet_cli_release_ubuntu/)|[![Build Status](http://dotnet-ci.cloudapp.net/buildStatus/icon?job=Private/dotnet_cli_release_windows_nt)](http://dotnet-ci.cloudapp.net/job/Private/job/dotnet_cli_release_windows_nt/)|[![Build Status](http://dotnet-ci.cloudapp.net/buildStatus/icon?job=Private/dotnet_cli_release_osx)](http://dotnet-ci.cloudapp.net/job/Private/job/dotnet_cli_release_osx/) |
## Prerequisites
In order to build dotnet-cli, you need the following installed on you machine
### For Windows
1. Visual Studio 2015 with Web Development Tools
* Beta8 is available here and should work: http://www.microsoft.com/en-us/download/details.aspx?id=49442
* Install `WebToolsExtensionsVS14.msi` and `DotNetVersionManager-x64.msi`
2. CMake (available from https://cmake.org/) is required to build the native host `corehost`
## Building/Running ## Building/Running
1. Run `build.cmd` or `build.sh` from the root 1. Run `build.cmd` or `build.sh` from the root
2. Use `artifacts/{os}-{arch}/stage2/dotnet` to try out the `dotnet` command. You can also add `artifacts/{os}-{arch}/stage2` to the PATH if you want to run `dotnet` from anywhere. 2. Use `artifacts/{os}-{arch}/stage2/dotnet` to try out the `dotnet` command. You can also add `artifacts/{os}-{arch}/stage2` to the PATH if you want to run `dotnet` from anywhere.
## Notes
Right now the CLI uses [DNX](https://github.com/aspnet/dnx) for NuGet restore.
## Visual Studio
* Requires VS 2015 with Web Development Tools installed to open in VS
* Beta8 is available here and should work: http://www.microsoft.com/en-us/download/details.aspx?id=49442
* Install `WebToolsExtensionsVS14.msi` and `DotNetVersionManager-x64.msi`
* Requires that you have a DNX installed (the build script _should_ set it up for you though)
* Compilation is not required before building, but you must run `dnu restore` (which comes from the DNX commands) after changing dependencies. If you add/remove dependencies in VS, it will run it for you
## Visual Studio Code ## Visual Studio Code
* You can also use Visual Studo code https://code.visualstudio.com/ * You can also use Visual Studo code https://code.visualstudio.com/

View file

@ -75,7 +75,10 @@ if errorlevel 1 goto fail
REM deploy corehost.exe to the output REM deploy corehost.exe to the output
copy "%HOST_DIR%\corehost.exe" "%STAGE1_DIR%" copy "%HOST_DIR%\corehost.exe" "%STAGE1_DIR%"
if errorlevel 1 goto fail
if exist "%HOST_DIR%\corehost.pdb" copy "%HOST_DIR%\corehost.pdb" "%STAGE1_DIR%" if exist "%HOST_DIR%\corehost.pdb" copy "%HOST_DIR%\corehost.pdb" "%STAGE1_DIR%"
if errorlevel 1 goto fail
echo Re-building dotnet tools with the bootstrapped version echo Re-building dotnet tools with the bootstrapped version
REM This should move into a proper build script of some kind once we are bootstrapped REM This should move into a proper build script of some kind once we are bootstrapped
@ -104,11 +107,14 @@ dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE2_DIR%" --c
if errorlevel 1 goto fail if errorlevel 1 goto fail
REM deploy corehost.exe to the output REM deploy corehost.exe to the output
copy "%HOST_DIR%/corehost.exe" "%STAGE2_DIR%" copy "%HOST_DIR%\corehost.exe" "%STAGE2_DIR%"
if exist "%HOST_DIR%/corehost.pdb" copy "%HOST_DIR/corehost.pdb" "%STAGE2_DIR%" if errorlevel 1 goto fail
if exist "%HOST_DIR%\corehost.pdb" copy "%HOST_DIR%\corehost.pdb" "%STAGE2_DIR%"
if errorlevel 1 goto fail
echo Crossgening Roslyn compiler ... echo Crossgening Roslyn compiler ...
call "%~dp0crossgen/crossgen_roslyn.cmd" "%STAGE2_DIR%" call "%~dp0crossgen\crossgen_roslyn.cmd" "%STAGE2_DIR%"
if errorlevel 1 goto fail if errorlevel 1 goto fail
REM Copy DNX in to stage2 REM Copy DNX in to stage2
@ -124,11 +130,11 @@ del "%REPOROOT%\test\TestApp\project.lock.json"
dotnet restore "%REPOROOT%\test\TestApp" --runtime "%RID%" --quiet dotnet restore "%REPOROOT%\test\TestApp" --runtime "%RID%" --quiet
dotnet publish "%REPOROOT%\test\TestApp" --framework "%TFM%" --runtime "%RID%" --output "%REPOROOT%\artifacts\%RID%\smoketest" dotnet publish "%REPOROOT%\test\TestApp" --framework "%TFM%" --runtime "%RID%" --output "%REPOROOT%\artifacts\%RID%\smoketest"
"%REPOROOT%/artifacts/%RID%/smoketest/TestApp" "%REPOROOT%/artifacts/%RID%/smoketest/TestApp" 2>nul >nul
if errorlevel 1 goto fail if errorlevel 1 goto fail
REM Check that a compiler error is reported REM Check that a compiler error is reported
dotnet compile "%REPOROOT%\test\compile\failing\SimpleCompilerError" --framework "%TFM%" >nul dotnet compile "%REPOROOT%\test\compile\failing\SimpleCompilerError" --framework "%TFM%" >nul 2>nul
if %errorlevel% == 0 goto fail if %errorlevel% == 0 goto fail
echo Bootstrapped dotnet to %STAGE2_DIR% echo Bootstrapped dotnet to %STAGE2_DIR%

View file

@ -273,12 +273,6 @@ namespace Microsoft.DotNet.Tools.Compiler
} }
return outputPath; return outputPath;
string intermediateOutputPath = Path.Combine(
context.ProjectFile.ProjectDirectory,
Constants.ObjDirectoryName,
configuration,
context.TargetFramework.GetTwoDigitShortFolderName());
} }
private static string GetIntermediateOutputPath(ProjectContext context, string configuration, string outputOptionValue) private static string GetIntermediateOutputPath(ProjectContext context, string configuration, string outputOptionValue)

View file

@ -2,6 +2,11 @@
#include "trace.h" #include "trace.h"
#include "utils.h" #include "utils.h"
#include <locale>
#include <codecvt>
static std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> g_converter;
bool pal::load_library(const char_t* path, dll_t& dll) bool pal::load_library(const char_t* path, dll_t& dll)
{ {
dll = ::LoadLibraryW(path); dll = ::LoadLibraryW(path);
@ -100,36 +105,12 @@ bool pal::get_own_executable_path(string_t& recv)
std::string pal::to_stdstring(const string_t& str) std::string pal::to_stdstring(const string_t& str)
{ {
// Calculate the size needed return g_converter.to_bytes(str);
auto length = ::WideCharToMultiByte(CP_ACP, 0, str.c_str(), -1, nullptr, 0, nullptr, nullptr);
// Allocate a string
auto buf = new char[length];
auto res = ::WideCharToMultiByte(CP_ACP, 0, str.c_str(), (int)str.length(), buf, length, nullptr, nullptr);
if (res == -1)
{
return std::string();
}
auto copied = std::string(buf);
delete[] buf;
return copied;
} }
pal::string_t pal::to_palstring(const std::string& str) pal::string_t pal::to_palstring(const std::string& str)
{ {
// Calculate the size needed return g_converter.from_bytes(str);
auto length = ::MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, nullptr, 0);
// Allocate a string
auto buf = new char_t[length];
auto res = ::MultiByteToWideChar(CP_ACP, 0, str.c_str(), (int)str.length(), buf, length);
if (res == -1)
{
return string_t();
}
auto copied = string_t(buf);
delete[] buf;
return copied;
} }
bool pal::realpath(string_t& path) bool pal::realpath(string_t& path)
@ -166,9 +147,7 @@ std::vector<pal::string_t> pal::readdir(const string_t& path)
auto handle = ::FindFirstFileW(search_string.c_str(), &data); auto handle = ::FindFirstFileW(search_string.c_str(), &data);
do do
{ {
string_t filepath(path); string_t filepath(data.cFileName);
filepath.push_back(DIR_SEPARATOR);
filepath.append(data.cFileName);
files.push_back(filepath); files.push_back(filepath);
} while (::FindNextFileW(handle, &data)); } while (::FindNextFileW(handle, &data));
::FindClose(handle); ::FindClose(handle);