New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet run -p, can not start a project #5992

Closed
Jupakabra opened this Issue Mar 10, 2017 · 2 comments

Comments

Projects
None yet
4 participants
@Jupakabra

Jupakabra commented Mar 10, 2017

Steps to reproduce

dotnet new console -o Project -n ConsoleApp
cd Project
dotnet restore
cd ..
dotnet run -p Project

Expected behavior

Project runs and prints out Hello World!.

Actual behavior

Unauthorized exception is always being thrown

Unhandled Exception: Microsoft.Build.Exceptions.InvalidProjectFileException: The project file could not be loaded. Access to the path 'D:\VisualC\Project' is denied.  D:\VisualC\Project ---> System.UnauthorizedAccessException: Access to the path 'D:\VisualC\Project' is denied.
   at System.IO.Win32FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)
   at System.IO.Win32FileSystem.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Microsoft.Build.Internal.XmlReaderExtension..ctor(String file)
   at Microsoft.Build.Construction.ProjectRootElement.LoadDocument(String fullPath, Boolean preserveFormatting)
   --- End of inner exception stack trace ---
   at Microsoft.Build.Shared.ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile(Boolean condition, String errorSubCategoryResourceName, BuildEventFileInfo projectFile, Exception innerException, String resourceName, Object[] args)
   at Microsoft.Build.Shared.ProjectFileErrorUtilities.ThrowInvalidProjectFile(BuildEventFileInfo projectFile, Exception innerException, String resourceName, Object[] args)
   at Microsoft.Build.Construction.ProjectRootElement.LoadDocument(String fullPath, Boolean preserveFormatting)
   at Microsoft.Build.Construction.ProjectRootElement..ctor(String path, ProjectRootElementCache projectRootElementCache, BuildEventContext buildEventContext, Boolean preserveFormatting)
   at Microsoft.Build.Construction.ProjectRootElement.CreateProjectFromPath(String projectFile, IDictionary`2 globalProperties, String toolsVersion, ILoggingService loggingService, ProjectRootElementCache projectRootElementCache, BuildEventContext buildEventContext, Boolean preserveFormatting)
   at Microsoft.Build.Construction.ProjectRootElement.<>c__DisplayClass199_0.<OpenProjectOrSolution>b__0(String path, ProjectRootElementCache cache)
   at Microsoft.Build.Evaluation.ProjectRootElementCache.Get(String projectFile, OpenProjectRootElement openProjectRootElement, Boolean isExplicitlyLoaded, Nullable`1 preserveFormatting)
   at Microsoft.Build.Construction.ProjectRootElement.OpenProjectOrSolution(String fullPath, IDictionary`2 globalProperties, String toolsVersion, ILoggingService loggingService, ProjectRootElementCache projectRootElementCache, BuildEventContext buildEventContext, Boolean isExplicitlyLoaded)
   at Microsoft.Build.Execution.ProjectInstance..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection)
   at Microsoft.Build.Execution.ProjectInstance..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion)
   at Microsoft.DotNet.Tools.Run.RunCommand.GetRunCommand()
   at Microsoft.DotNet.Tools.Run.RunCommand.Start()
   at Microsoft.DotNet.Tools.Run.RunCommand.<>c__DisplayClass0_0.<Run>b__0()
   at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
   at Microsoft.DotNet.Tools.Run.RunCommand.Run(String[] args)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)

This used to work with previous version, it now only works with full path:
dotnet run -p Project\ConsoleApp.csproj
or being inside a Project folder:
dotnet run

Environment data

.NET Command Line Tools (1.0.1)

Product Information:
 Version:            1.0.1
 Commit SHA-1 hash:  005db40cd1

Runtime Environment:
 OS Name:     Windows
 OS Version:  6.1.7601
 OS Platform: Windows
 RID:         win7-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.1

@livarcocc livarcocc added this to the 2.0.0 milestone Mar 13, 2017

@livarcocc livarcocc added the Parser label Mar 13, 2017

@jskeet

This comment has been minimized.

Show comment
Hide comment
@jskeet

jskeet Mar 22, 2017

I'm surprised this significant (IMO) regression vs the old SDK hasn't seen more interest (and that the only plan is to fix it in 2.0.0 rather than in a bugfix release for 1.x).

Note that the documentation for dotnet run explicitly says you can specify a directory (emphasis mine):

-p: Specifies the path to the project file to run. It can be a path to a csproj file or to a directory containing a csproj file. It defaults to current directory if not specified.

jskeet commented Mar 22, 2017

I'm surprised this significant (IMO) regression vs the old SDK hasn't seen more interest (and that the only plan is to fix it in 2.0.0 rather than in a bugfix release for 1.x).

Note that the documentation for dotnet run explicitly says you can specify a directory (emphasis mine):

-p: Specifies the path to the project file to run. It can be a path to a csproj file or to a directory containing a csproj file. It defaults to current directory if not specified.

@enricosada

This comment has been minimized.

Show comment
Hide comment
@enricosada

enricosada Mar 22, 2017

Collaborator

I repro that a lot, sigh, so 👍

Collaborator

enricosada commented Mar 22, 2017

I repro that a lot, sigh, so 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment