Skip to content

Build fails if path contains # symbol #5

@phizch

Description

@phizch

I tried following the steps in the VSIX cookbook, but I got a build error:

CreatePkgDef : error : 
  ProvideCodeBaseAttribute: Could not load specified assembly: 'Community.VisualStudio.Toolkit' 
  reason: Could not load file or assembly 'file:///C:\Dev\Phizch\Community.VisualStudio.Toolkit.dll' or one of its dependencies.
  The system cannot find the file specified.

It took me several hours, but I finally tracked down the cause: My solution path.

C:\Dev\Phizch\C#\Visual Studio\InsertGuid

It worked without a problem when I moved the solution to:

C:\Dev\Phizch\Csharp\Visual Studio\InsertGuid

How to reproduce:

Clone this repsoitory into a folder whose path contains #
Try to compile the InsertGuid project.

Start a Developer Command Prompt for VS 2022 Preview and run the following commands

cd \
md Test#
cd Test#
git clone https://github.com/VsixCommunity/Samples.git
cd Samples
devenv Samples.sln /Build Debug

Cause:

I'm not sure which org/repository the bug resides in, but I stumbled across it while trying to follow the tutorial for this sample.
Anyway, I know what the bug is. Just not where it is.

Someone did this: new Uri( "file:///" + projectObjPath );¹ instead of new Uri( new Uri( "file:///" ), projectObjPath);.
This results in practically the same incorrect uri as in the error message above.

file:///C:/Dev/Phizch/Community.VisualStudio.Toolkit.dll

The only difference is that the directory separator is \ in the error and / from ¹.

Fix:

Use Uri( Uri baseUri, string? relativeUri) constructor.

Workaround

Not use # in anywhere in the path. C:\Dev\Phizch\C#\ would be nice, and has worked for me so far, but I can live with Csharp.

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