无法在工作区中找到文件,或者您无权访问它 [英] Files could not be found in your workspace, or you do not have permission to access it

查看:1087
本文介绍了无法在工作区中找到文件,或者您无权访问它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我意识到这个问题之前已经被问到过,但我还没有找到具体解决这个问题的答案。

I realize this question has been asked before, but I haven't found an answer that specifically addresses this issue.

我使用Visual Studio 2015 Update 3在Core 1(MVC 6)的项目中,Angular2和该项目位于TFS中。我正在使用Gulp-watch来复制html / css / js文件,并且这个工作时间最长。我的.tfignore文件中包含大部分的wwwroot文件,其中包括我的app文件夹,其中所有这些文件都被gulp和gulp-watch复制/清除。我知道tfignore设置正在工作,因为TFS不会尝试提交这些文件。然而,当Gulp对该文件夹进行清理时,我会得到一个无法在您的工作空间中找到,或者您没有权限访问它。这个TFS检查会减慢构建时的流程,这足以解决问题,但有时Gulp-Watch进程失败,因为它没有复制特定html文件的权限。 gulp-watch复制错误是 EPERM:操作不允许,在Error(native)处打开'dashboard.component.html'进程终止于代码1。如果我清理然后重新运行Gulp副本没有权限问题。我在想,尽管这些文件是无效的,但TFS可能在这个问题上扮演了一个角色。

I'm using Visual Studio 2015 Update 3 on a project with Core 1 (MVC 6), Angular2 and the project is in TFS. I'm using Gulp-watch to copy html/css/js files over as I work on them and this works most of the time. I have most of wwwroot in my .tfignore file including my "app" folder where all those files are being copied/cleaned by gulp and gulp-watch. I know tfignore settings are working because TFS is not trying to commit those files. However when Gulp does a clean on that folder I get a "could not be found in your workspace, or you do not have permission to access it.". This TFS check slows down the process when I build and that's enough to want to fix it, but at times the Gulp-Watch process fails because it doesn't have permissions to copy a specific html file. The gulp-watch copy error is EPERM: operation not permitted, open 'dashboard.component.html' at Error (native) Process terminated with code 1. If I clean and then re-run the Gulp copy there are no permission issues. I'm thinking that possibly TFS is playing a part in this problem even though those files are tfignored.

PS。我读过,你可以使用gulp-plumber来避免错误停止,但我试图找出是什么导致wwwroot中的TFS错误,并希望作为结果首先解决频繁的文件复制错误。

PS. I've read that you can use gulp-plumber to avoid the stops on errors, but I'm trying to figure out what is causing the TFS errors in wwwroot and hopefully as a result fix the frequent file copy errors first.

有问题的代码:

Gulp code in question:

var appDestPath = './wwwroot/app/';

gulp.task('clearAppDestinationFolderHtml',
    function () {
        return gulp.src(appDestPath + '**/*.html')
            .pipe(clean());
    });

gulp.task('clearAppDestinationFolderCss',
    function () {
        return gulp.src(appDestPath + '**/*.css')
            .pipe(clean());
    });

gulp.task('moveHtml', function () {
    gulp.start('clearAppDestinationFolderHtml');
    gulp.src(['app/**/*.html']).pipe(gulp.dest('./wwwroot/app/'));
});

gulp.task('moveCss', function () {
    gulp.start('clearAppDestinationFolderCss');
    gulp.src(['app/**/*.css']).pipe(gulp.dest('./wwwroot/app/'));
});

gulp.task('watch', function () {
    gulp.watch('app/**/*.html', ['moveHtml']);
    gulp.watch('app/**/*.css', ['moveCss']);
});

目标文件夹的清理仅在尝试修复此问题时才添加。我意识到清洁与副本同时运行,并可能导致它自己的问题。我最近也试过这段代码,以便只拷贝特定的文件,并且与之前的(操作不允许,打开'wwwroot \app\User\Components\app .conent.ts')

The cleaning of the destination folder was only added while trying to fix this problem. I'm realizing that the clean is running at the same time as the copy and could cause it's own issues. I just recently tried this code as well to copy only the specific file changed and ended up with the same error as before (operation not permitted, open 'wwwroot\app\User\Components\app.component.ts'):

gulp.task('watch2', function () {
    return gulp.watch('./app/**/*', function(obj){
        if( obj.type === 'changed') {
            gulp.src( obj.path, { "base": "./app/"})
            .pipe(gulp.dest(appDestPath));
        }
    })
});

这里是我的.tfignore文件:

Also here is my .tfignore file:

wwwroot/app
wwwroot/scripts
wwwroot/libs
wwwroot/_references.js
app/*.js
app/*.js.map
typings


推荐答案

如果你只是将文件移动到 / app 目录,它们可能仍然是只读的。 TFS源代码管理下的文件是只读的。如果是这种情况, gulp-chmod 插件可以删除该只读标志。

If you're only moving files to the /app directory, they're probably still read-only. Files under TFS source control are read-only. If that's the case, the gulp-chmod plugin can remove that read-only flag.

此外,吞食已弃用,以支持 del

Also, gulp-clean is deprecated in favor of del.

至于依赖关系,这并不难于处理3.您可以使用名为的插件运行 - 序列(这是一个临时修复,直到gulp 4发布)或者你可以设置对任务的依赖

As for the dependency, that's not hard to do with gulp 3. You can either use a plugin called run-sequence (which is a temporary fix until gulp 4 is released) or you can just set a dependency on the task

var gulp = require('gulp'),
    $ = require('gulp-load-plugins')(),
    del = require('del'),
    appDestPath = './app/';


gulp.task('clean:html', () => {
    return del([
        appDestPath + '**/*.html'
    ]);
});

gulp.task('clean:css', () => {
    return del([
        appDestPath + '**/*.css'
    ]);
});

gulp.task('moveHtml', ['clean:html'], function () {
    gulp.src(['src/**/*.html'])
        .pipe($.chmod(666))
        .pipe(gulp.dest('./app/'));
});

gulp.task('moveCss', ['clean:css'], function () {
    gulp.src(['src/**/*.css'])
        .pipe($.chmod(666))
        .pipe(gulp.dest('./app/'));
});

gulp.task('watch', () => {
    gulp.watch('src/**/*.html', ['moveHtml']);
    gulp.watch('src/**/*.css', ['moveCss']);
});

这篇关于无法在工作区中找到文件,或者您无权访问它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆