/// <summary>
        /// Resolves the path.
        /// </summary>
        /// <param name="fileName">The path.</param>
        /// <param name="hintPath">The transformer path.</param>
        /// <returns></returns>
        public string ResolvePath(string fileName, string hintPath)
        {
            if (_fileSystem.IsPathRooted(fileName))
            {
                return(fileName);
            }

            if (!string.IsNullOrEmpty(hintPath))
            {
                string fullName = _fileSystem.Combine(hintPath, fileName);
                if (_fileSystem.FileExists(fullName))
                {
                    return(fullName);
                }
            }

            if (!string.IsNullOrEmpty(_fileSystem.EntryAssemblyLocation))
            {
                var    directoryName = _fileSystem.GetDirectoryName(_fileSystem.EntryAssemblyLocation);
                string fullName      = _fileSystem.Combine(directoryName, fileName);
                if (_fileSystem.FileExists(fullName))
                {
                    return(fullName);
                }
            }
            return(fileName);
        }
Example #2
0
        public ProcessInfo Wrap(ProcessInfo processInfo)
        {
            var workingDirectory = processInfo.WorkingDirectory;

            if (!_info.SolutionDirectory.IsEmpty)
            {
                if (_fileSystem.IsPathRooted(_info.SolutionDirectory))
                {
                    workingDirectory = _info.SolutionDirectory;
                }
                else
                {
                    workingDirectory = workingDirectory + _info.SolutionDirectory;
                }
            }

            return(new ProcessInfo(
                       !processInfo.Executable.IsEmpty ? processInfo.Executable : _info.DotnetExecutable,
                       workingDirectory,
                       processInfo.Arguments,
                       processInfo.Variables.Concat(_info.EnvironmentVariables)));
        }
Example #3
0
 // HACK: Filter out assemblies in the GAC by checking if full path is specified.
 private static bool ShouldLoadAssembly(IFileSystem fileSystem, IAssemblyUtility assemblyUtility, string assembly)
 {
     return(fileSystem.IsPathRooted(assembly) && assemblyUtility.IsManagedAssembly(assembly));
 }
Example #4
0
 // HACK: Filter out assemblies in the GAC by checking if full path is specified.
 private static bool ShouldLoadAssembly(IFileSystem fileSystem, IAssemblyUtility assemblyUtility, string assembly)
 {
     return fileSystem.IsPathRooted(assembly) && assemblyUtility.IsManagedAssembly(assembly);
 }
Example #5
0
 // HACK: Filter out assemblies in the GAC by checking if full path is specified.
 private static bool ShouldLoadAssembly(IFileSystem fileSystem, string assembly)
 {
     return fileSystem.IsPathRooted(assembly);
 }
Example #6
0
 // HACK: Filter out assemblies in the GAC by checking if full path is specified.
 private static bool ShouldLoadAssembly(IFileSystem fileSystem, string assembly)
 {
     return(fileSystem.IsPathRooted(assembly));
 }
Example #7
0
        private string ParseFile(string path, IEnumerable <string> file, ref List <string> usings, ref List <string> rs, ref List <string> loads)
        {
            var fileList  = file.ToList();
            var firstCode = fileList.FindIndex(l => PreProcessorUtil.IsNonDirectiveLine(l));

            var firstBody = fileList.FindIndex(l => PreProcessorUtil.IsNonDirectiveLine(l) && !PreProcessorUtil.IsUsingLine(l));

            // add #line before the actual code begins
            // +1 because we are in a zero indexed list, but line numbers are 1 indexed
            // we need to keep the original position of the actual line
            if (firstBody != -1)
            {
                _logger.DebugFormat("Added #line statement for file {0} at line {1}", path, firstBody);
                fileList.Insert(firstBody, string.Format(@"#line {0} ""{1}""", firstBody + 1, path));
            }

            for (var i = 0; i < fileList.Count; i++)
            {
                var line = fileList[i];
                if (PreProcessorUtil.IsUsingLine(line))
                {
                    usings.Add(line);
                }
                else if (PreProcessorUtil.IsRLine(line))
                {
                    if (i < firstCode)
                    {
                        rs.Add(line);
                    }
                    else
                    {
                        fileList[i] = string.Empty;
                    }
                }
                else if (PreProcessorUtil.IsLoadLine(line))
                {
                    if ((i < firstCode || firstCode < 0) && !loads.Contains(line))
                    {
                        var filepath    = PreProcessorUtil.GetPath(PreProcessorUtil.LoadString, line);
                        var filecontent = _fileSystem.IsPathRooted(filepath)
                                              ? _fileSystem.ReadFileLines(filepath)
                                              : _fileSystem.ReadFileLines(_fileSystem.CurrentDirectory + @"\" + filepath);

                        if (filecontent != null)
                        {
                            loads.Add(line);
                            _logger.DebugFormat("Parsing file {0}", path);
                            var parsed = ParseFile(filepath, filecontent, ref usings, ref rs, ref loads);
                            fileList[i] = parsed;
                        }
                    }
                    else
                    {
                        fileList[i] = string.Empty;
                    }
                }
            }

            var result = string.Join(_fileSystem.NewLine, fileList.Where(line => !PreProcessorUtil.IsUsingLine(line) && !PreProcessorUtil.IsRLine(line)));

            return(result);
        }