简体   繁体   中英

Replace nuget package depending on config

I'm writing API system tests for one big system that referenced nuget package dll from another our system. What I'm going to achieve is to replace this package with fake one. It helps to avoid test both systems together and do it separately. But how can I do it. Can I change nuget source depends on config transformation for instance? Or some another way to do it?

There are a couple of ways to do this and I would recommend not changing your config files using transforms.

In your tests you can specify a new repositoryPath in nuget.config that points to a separate packages folder if you are using packages.config. If you are using project.json you can use the glocalPackagesFolder property.

In this new packages location, you can drop in the the fake package with the same package id and version and the application under test would pick the fake package from there. This way you dont really have to modify your source code. For more information around your nuget.config, check out the documentation here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM