MsBuild: Modifying ProjectReference to Reference

In our environment, we have two internal structures and a separate website. During development, references to internal structures are usually set in references to the tp project. However, as soon as we move on to the release, the built-in frameworks are installed in the GAC, as they are used for multiple instances of the website on each server. All ProjectReferences are manually changed, and the links, as well as assemblies and websites, are compiled and deployed.

I am trying to automate this process. What is the best way to solve these problems? I started learning MsBuild in an attempt to achieve this, but I am completely confused. Any pointers and / or suggestions on how to proceed?

+4
source share
2 answers

As far as I know, there should not be a need to switch from links to links to links to files simply because the assembly is registered in the GAC - as long as the link project is strictly typed at the point where it is built, the link must be valid.

Clarification:

There is no fundamental difference between a GAC โ€‹โ€‹link and a file link - if you have a link to a strongly named assembly, and this assembly is placed in the GAC, then the final application will load this assembly from the GAC.

See this link for more information on how the runtime finds reference assemblies:

FYI. I believe that it is recommended not to refer to assemblies that are physically located in the GAC, and that you instead refer to a strongly named assembly before it is placed in the GAC (not to be confused with that, the assembly must be installed on the PAC on the machine end user)

+3
source

If you leave the project links, MSBUILD will copy all the project links in the form of DLLs to the target bin directory of the site, even if you installed these DLLs in the GAC, and I assume that you want to change this to the release level - so that the space can be saved .

I also assume that you intend to do this only in Release Release, and not in the development branch of your original control. Because if you do this in all branches of the source control, manual execution is the best and fastest way to do this for a one-time change.

To do this in MSBUILD, you need to create a custom task that can modify the project file. The project file is an XML file, so you can use XPath as your custom task in MSBUILD. In the project file, you will find tags for โ€œfor your projects that you are referencing. You will need to replace them with tags.โ€ Use existing tag examples in your project to see how it should look.

Sorry, I donโ€™t have a sample code for this - doing it this way will be a little deliberate, as there will be many things that need to be taken into account, and this may not be feasible.

+1
source

All Articles