Exemple #1
0
        public void ConfigureAll(Configuration conf, Target target)
        {
            conf.ProjectPath     = RootPath;
            conf.ProjectFileName = "[project.Name].[target.DevEnv]";
            conf.Output          = Configuration.OutputType.DotNetClassLibrary;

            conf.Options.Add(Options.CSharp.LanguageVersion.CSharp5);

            conf.Defines.Add(_projectInfo.Defines.ToArray());

            foreach (var projectReference in _projectInfo.ProjectReferences)
            {
                conf.AddPrivateDependency(target, projectReference);
            }

            DebugProjectGenerator.DebugProjectExtension.AddReferences(conf, _projectInfo.References);
            DebugProjectGenerator.DebugProjectExtension.AddSharpmakePackage(conf);

            // set up custom configuration only to setup project
            if (string.CompareOrdinal(conf.ProjectPath.ToLower(), RootPath.ToLower()) == 0 &&
                _projectInfo.IsSetupProject)
            {
                conf.SetupProjectOptions(_projectInfo.StartArguments);
            }
        }
        /// <summary>
        /// Initialises the packages store by validating parameters, then connecting to the network share.
        /// </summary>
        /// <exception cref="ArgumentNullException"> if <paramref name="DriveLetter"/> is null or contains only whitespace or <paramref name="RootPath"/> is null or contains only whitespace or <paramref name="UserName"/> is null or contains only whitespace or <paramref name="AccessKey"/> is null or contains only whitespace or <paramref name="FileShareName"/> is null or contains only whitespace.</exception>
        /// <exception cref="ArgumentOutOfRangeException"> if <paramref name="DriveLetter"/> does not match ^[A-Za-z]:$ or <paramref name="RootPath"/> does not start with <paramref name="DriveLetter"/></exception>
        private void InitPackageStore()
        {
            _logger = Logger.Initialise(LogFileName);
            _fileSystemOperations.Logger = _logger;

            if (string.IsNullOrWhiteSpace(DriveLetter))
            {
                throw new ArgumentNullException("DriveLetter");
            }
            if (!Regex.IsMatch(DriveLetter, "^[A-Za-z]:$"))
            {
                throw new ArgumentOutOfRangeException("DriveLetter", "DriveLetter must be a single drive letter (A-Z) followed by a colon");
            }

            if (string.IsNullOrWhiteSpace(RootPath))
            {
                throw new ArgumentNullException("RootPath");
            }
            if (!RootPath.ToLower().StartsWith(DriveLetter.ToLower()))
            {
                throw new ArgumentOutOfRangeException("RootPath", "RootPath must be on the drive specified by DriveLetter (ie, if DriveLetter='P:', then RootPath must start with 'P:\'");
            }

            if (string.IsNullOrWhiteSpace(UserName))
            {
                throw new ArgumentNullException("UserName");
            }

            if (string.IsNullOrWhiteSpace(AccessKey))
            {
                throw new ArgumentNullException("AccessKey");
            }

            if (string.IsNullOrWhiteSpace(FileShareName))
            {
                throw new ArgumentNullException("FileShareName");
            }

            var uncPath = string.Format(@"\\{0}.file.core.windows.net\{1}", UserName, FileShareName);

            try
            {
                _logger.DebugFormat("Mapping network share '{0}' to drive '{1}' with username '{2}'", uncPath, DriveLetter, UserName);
                var stopWatch = new Stopwatch();
                stopWatch.Start();
                _fileShareMapper.Mount(DriveLetter, uncPath, UserName, AccessKey, _logger);
                stopWatch.Stop();
                _logger.DebugFormat("Drive mapping successful and took {0} milliseconds.", stopWatch.ElapsedMilliseconds);
            }
            catch (Exception ex)
            {
                _logger.Error(String.Format("Exception occurred mapping drive '{0}' to '{1}' with username '{2}'", DriveLetter, uncPath, UserName), ex);
                throw;
            }
        }
        public void ConfigureAll(Configuration conf, Target target)
        {
            conf.ProjectPath     = RootPath;
            conf.ProjectFileName = "[project.Name].[target.DevEnv]";
            conf.Output          = Configuration.OutputType.DotNetClassLibrary;

            DebugProjectGenerator.AddSharpmakePackage(conf);

            conf.ReferencesByPath.AddRange(DebugProjectGenerator.DebugProjects[GetType()].References);
            foreach (var projectReference in DebugProjectGenerator.DebugProjects[GetType()].ProjectReferences)
            {
                conf.AddPrivateDependency(target, projectReference);
            }

            // set up custom configuration only to setup project
            if (string.CompareOrdinal(conf.ProjectPath.ToLower(), RootPath.ToLower()) == 0)
            {
                conf.SetupProjectOptions();
            }
        }