Skip to content

Pointing to a non-existent csproj produces a confusing error message #99

@shilangyu

Description

@shilangyu

When trying to generate contracts using the project flag and then pointing to a non-existent file produces an exception that does indeed mention lack of the file, but also mentions other problems which might be misleading. Example:

 Generator script failed with: Cannot compile project or generate contracts: The project file could not be loaded. Could not load file or assembly 'System.Security.Permissions, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
   /home/shilangyu/coding/work/contractsgenerator-dart/packages/leancode_contracts_generator/contractsgenerator/examples/project/aggregated/Combined/Combined.csproj
 At
    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.CreateProjectFromPath(String projectFile, ProjectRootElementCacheBase projectRootElementCache, Boolean preserveFormatting)
    at Microsoft.Build.Construction.ProjectRootElement.<>c.<OpenProjectOrSolution>b__208_0(String path, ProjectRootElementCacheBase 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, ProjectRootElementCacheBase projectRootElementCache, Boolean isExplicitlyLoaded)
    at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion)
    at LeanCode.ContractsGenerator.Compilation.MSBuild.MSBuildHelper.RestoreProjects(IReadOnlyCollection`1 projectPaths, IDictionary`2 globalProperties) in /home/runner/work/contractsgenerator/contractsgenerator/src/LeanCode.ContractsGenerator/Compilation/MSBuild/MSBuildHelper.cs:line 69
    at LeanCode.ContractsGenerator.Compilation.ProjectLoader.LoadProjectsAsync(IEnumerable`1 projectPaths) in /home/runner/work/contractsgenerator/contractsgenerator/src/LeanCode.ContractsGenerator/Compilation/ProjectLoader.cs:line 24
    at LeanCode.ContractsGenerator.Compilation.ContractsCompiler.CompileProjectsAsync(IEnumerable`1 projectPaths) in /home/runner/work/contractsgenerator/contractsgenerator/src/LeanCode.ContractsGenerator/Compilation/ContractsCompiler.cs:line 68
    at LeanCode.ContractsGenerator.Program.HandleProjectAsync(ProjectOptions p) in /home/runner/work/contractsgenerator/contractsgenerator/src/LeanCode.ContractsGenerator/Program.cs:line 114
    at LeanCode.ContractsGenerator.Program.Main(String[] args) in /home/runner/work/contractsgenerator/contractsgenerator/src/LeanCode.ContractsGenerator/Program.cs:line 61

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions