Sdk: dotnet run -p, can not start a project

Created on 10 Mar 2017  路  2Comments  路  Source: dotnet/sdk

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
Parser

Most helpful comment

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.

All 2 comments

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.

I repro that a lot, sigh, so 馃憤

Was this page helpful?
0 / 5 - 0 ratings