Пример #1
0
        protected override void AddFileToProject(string path)
        {
            if (ExcludeFile(path))
            {
                return;
            }

            string folderPath = Path.GetDirectoryName(path);
            string fullPath   = FileSystemUtility.GetFullPath(EnvDTEProjectUtility.GetFullPath(EnvDTEProject), path);

            // Add the file to project or folder
            EnvDTEProjectItems container = EnvDTEProjectUtility.GetProjectItems(EnvDTEProject, folderPath, createIfNotExists: true);

            if (container == null)
            {
                throw new ArgumentException(
                          String.Format(
                              CultureInfo.CurrentCulture,
                              Strings.Error_FailedToCreateParentFolder,
                              path,
                              ProjectName));
            }
            AddFileToContainer(fullPath, folderPath, container);

            NuGetProjectContext.Log(MessageLevel.Debug, Strings.Debug_AddedFileToProject, path, ProjectName);
        }
Пример #2
0
        public override void AddFile(string path, System.Action <Stream> writeToStream)
        {
            // ensure the parent folder is created before adding file to the project
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            EnvDTEProjectUtility.GetProjectItems(EnvDTEProject, Path.GetDirectoryName(path), createIfNotExists: true);
            base.AddFile(path, writeToStream);
        }
Пример #3
0
        protected virtual void AddFileToProject(string path)
        {
            if (ExcludeFile(path))
            {
                return;
            }

            // Get the project items for the folder path
            string folderPath = Path.GetDirectoryName(path);
            string fullPath   = FileSystemUtility.GetFullPath(ProjectFullPath, path);

            ThreadHelper.Generic.Invoke(() =>
            {
                EnvDTEProjectItems container = EnvDTEProjectUtility.GetProjectItems(EnvDTEProject, folderPath, createIfNotExists: true);
                // Add the file to project or folder
                AddFileToContainer(fullPath, folderPath, container);
            });

            NuGetProjectContext.Log(MessageLevel.Debug, Strings.Debug_AddedFileToProject, path, ProjectName);
        }