Skip to content
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

[Bug]: With Package source mapping package get installed from not active source on PMUI for PR project #11236

Closed
erdembayar opened this issue Sep 16, 2021 · 10 comments
Labels
Area:PackageSourceMapping Issues related to the package source mapping feature Functionality:Install The install command in VS/nuget.exe Product:VS.Client Style:PackageReference Type:Bug

Comments

@erdembayar
Copy link
Contributor

erdembayar commented Sep 16, 2021

NuGet Product Used

Visual Studio Package Management UI

Product Version

n/a

Worked before?

n/a

Impact

It bothers me. A fix would be nice

Repro Steps & Context

I discovered this playing with localization. As you can see on video Contoso.MVC.ASP get installed from "encyclopaedia" repository even though that package was mapped to "encyclopædia".

2

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="globalPackagesFolder" value="globalPackagesFolder" />
  </config>
  <packageSources>
    <clear />
    <add key="encyclopaedia" value="C:\xxxx\NamespaceTestPackages\PublicRepository" />
    <!-- <add key="Encyclopaedia" value="https://api.nuget.org/v3/index.json" /> -->
    <add key="encyclopædia" value="C:\xxxx\NamespaceTestPackages\PrivateRepository" />
    <!-- <add key="encyclopædia" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vssdk/nuget/v3/index.json" /> -->
  </packageSources>
    <packageSourceMapping>
        <packageSource key="encyclopaedia">
            <package pattern="Contoso.*" />
            <package pattern="测试更*" />
        </packageSource>            
        <packageSource key="encyclopædia">
            <package pattern="Contoso.MVC.*" />
        </packageSource>    
    </packageSourceMapping>  
</configuration>

Verbose Logs

Restoring packages for C:\NuGetProj\IssueRepro\11182\11182\11182.csproj...
Installed Contoso.MVC.ASP 1.0.0 from C:\xxxx\NamespaceTestPackages\PrivateRepository with content hash obFXJR2oXmb4gHYhVEDgbwwcu4IznlmJHzC06xLz9aNlyXET/DRbej47tlbWbpxADBpJAVV7yikQnadOAC9GrQ==.
Installing NuGet package Contoso.MVC.ASP 1.0.0.
Committing restore...

@erdembayar erdembayar added Type:Bug Triage:Untriaged Area:PackageSourceMapping Issues related to the package source mapping feature Functionality:Install The install command in VS/nuget.exe Product:VS.Client Style:PackageReference labels Sep 16, 2021
@erdembayar erdembayar reopened this Sep 16, 2021
@erdembayar
Copy link
Contributor Author

@kartheekp-ms @aortiz-msft
It looks minor bug, in quick glimpse I tried to fix, but couldn't find where is the issue.

@kartheekp-ms
Copy link
Contributor

kartheekp-ms commented Sep 16, 2021

Can you please provide the exact repro steps? The reason is if the settings are modified after the solution has been loaded then new settings will not be still effective. AFAIK, this behavior is by design as of now for NuGet.

@erdembayar
Copy link
Contributor Author

@kartheekp-ms
Please watch above gif video for repro steps. Settings file was not modified after loading.
11182.zip
You can use any package name instead of Contoso.MVC.ASP from your local.

@kartheekp-ms
Copy link
Contributor

kartheekp-ms commented Sep 16, 2021

@erdembayar - Looking at the verbose logs, configuration and gif file I think the behavior is working as expected. The reason is, as per the source mapping configuration, the package Contoso.MVC.ASP should be installed from encyclopædia - C:\xxxx\NamespaceTestPackages\PrivateRepository source and the verbose logs confirm that package has been installed from PrivateRepository which is the expected source for that package.

Installed Contoso.MVC.ASP 1.0.0 from C:\xxxx\NamespaceTestPackages\PrivateRepository with content hash obFXJR2oXmb4gHYhVEDgbwwcu4IznlmJHzC06xLz9aNlyXET/DRbej47tlbWbpxADBpJAVV7yikQnadOAC9GrQ==.

I unzipped your solution and followed below steps to reproduce issue.

  1. Create a local folder named PublicRepository in my local machine
  2. Create a local folder named PrivateRepository in my local machine
  3. Copied Contoso.MVC.ASP package into the 2 folders mentioned above
  4. Added source mapping settings to nuget.config file
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="globalPackagesFolder" value="globalPackagesFolder" />
  </config>
  <packageSources>
    <clear />
    <add key="encyclopaedia" value="C:\Users\xxx\source\PublicRepository" />
    <add key="encyclopædia" value="C:\Users\xxx\source\PrivateRepository" />
  </packageSources>
    <packageSourceMapping>
        <packageSource key="encyclopaedia">
            <package pattern="Contoso.*" />
            <package pattern="测试更*" />
        </packageSource>            
        <packageSource key="encyclopædia">
            <package pattern="Contoso.MVC.*" />
        </packageSource>    
    </packageSourceMapping>  
</configuration>
  1. Opened 11182.Sln in VS 2022
  2. Navigated to PM UI and selected encyclopaedia as package source
  3. Install Contoso.MVC.ASP package from the UI
  4. Package installed from C:\Users\xxx\source\PrivateRepository which is encyclopædia source and matches with the source mapping configuration

image

Please let me know if I missed any step while reproducing this issue. If you are okay with the behavior please feel free to close this issue.

@kartheekp-ms
Copy link
Contributor

By mistake I pressed Close with comment while adding above comment.

@erdembayar
Copy link
Contributor Author

  1. Package installed from C:\Users\xxx\source\PrivateRepository which is encyclopædia source and matches with the source mapping configuration

But your current PMUI selection is not encyclopædia, but it's "encyclopaedia".
Just replace "encyclopædia" with "Public" and ""encyclopaedia". with "Private" and try same action, it wouldn't restore.

@kartheekp-ms
Copy link
Contributor

But your current PMUI selection is not encyclopædia, but it's "encyclopaedia".

I agree. I copied the package to the both of the sources and selected encyclopaedia as source in PM UI. When I clicked on Install the package is installed from encyclopædia source as per source mapping configuration.

Just replace "encyclopædia" with "Public" and ""encyclopaedia". with "Private" and try same action, it wouldn't restore.

I changed the nuget.config as follows

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="globalPackagesFolder" value="globalPackagesFolder" />
  </config>
  <packageSources>
    <clear />
    <add key="encyclopædia" value="C:\Users\xxx\source\PublicRepository" />
    <add key="encyclopaedia" value="C:\Users\xxx\source\PrivateRepository" />
  </packageSources>
    <packageSourceMapping>
        <packageSource key="encyclopaedia">
            <package pattern="Contoso.*" />
            <package pattern="测试更*" />
        </packageSource>            
        <packageSource key="encyclopædia">
            <package pattern="Contoso.MVC.*" />
        </packageSource>    
    </packageSourceMapping>  
</configuration>

Clicked on Install in PM UI selecting encyclopædia as package source, then package installed from C:\Users\xxx\source\PublicRepository source as per source mapping configuration

Restoring packages for C:\Users\xxx\Downloads\11182\11182\11182\11182.csproj...
Installed Contoso.MVC.ASP 1.0.0 from C:\Users\xxx\source\PublicRepository with content hash pTkcni3UMv6vBG6s4dVhU5FxScsIJyolVuY2QydudpzZAE1me09lkxkyRDML4OqO1tqgagV4A7Nz7abedKTNyg==.
Installing NuGet package Contoso.MVC.ASP 1.0.0.
Committing restore...
Writing assets file to disk. Path: C:\Users\xxx\Downloads\11182\11182\11182\obj\project.assets.json

I even tried clearing global package folder, uninstall the package, change the source in PM UI to encyclopaedia, Installed the package, the restore logs below indicate that package installed from the expected source encyclopædia - C:\Users\xxx\source\PublicRepository

Restoring packages for C:\Users\xxx\Downloads\11182\11182\11182\11182.csproj...
Installed Contoso.MVC.ASP 1.0.0 from C:\Users\xxx\source\PublicRepository with content hash pTkcni3UMv6vBG6s4dVhU5FxScsIJyolVuY2QydudpzZAE1me09lkxkyRDML4OqO1tqgagV4A7Nz7abedKTNyg==.
Installing NuGet package Contoso.MVC.ASP 1.0.0.

@erdembayar
Copy link
Contributor Author

erdembayar commented Sep 17, 2021

Please try with following.
I replaced "encyclopædia" with "Public" and ""encyclopaedia". with "Private" and try same action, select Public as active source, it wouldn't restore.


<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="globalPackagesFolder" value="globalPackagesFolder" />
  </config>
  <packageSources>
    <clear />
    <add key="Public" value="C:\Users\xxx\source\PublicRepository" />
    <add key="Private" value="C:\Users\xxx\source\PrivateRepository" />
  </packageSources>
    <packageSourceMapping>
        <packageSource key="Public">
            <package pattern="Contoso.*" />
            <package pattern="测试更*" />
        </packageSource>            
        <packageSource key="Private">
            <package pattern="Contoso.MVC.*" />
        </packageSource>    
    </packageSourceMapping>  
</configuration>

@kartheekp-ms
Copy link
Contributor

kartheekp-ms commented Sep 17, 2021

Changed the config file and followed repro steps mentioned in above comment. #11236 (comment)

I still see the package installed from private package source.

image

Let's sync-up offline to make sure I am following the correct repro steps.

@kartheekp-ms
Copy link
Contributor

synced offline with @erdembayar. This behavior is expected now. Hence closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:PackageSourceMapping Issues related to the package source mapping feature Functionality:Install The install command in VS/nuget.exe Product:VS.Client Style:PackageReference Type:Bug
Projects
None yet
Development

No branches or pull requests

3 participants