简体   繁体   中英

Shipping msbuild task as nuget

I need your help.

I'm developing an msbuild task that performs certain actions upon msbuild.

I want my users to be able to download and install a nuget package and once the package is installed the build task will be part of the build process.

I know how to release a nuget package and i know how to includes a custom targets file together with the nuget, what i don't know is how to add the import statement to the csproj upon nuget installation:

Is there a way to do so or am i asking for too much?

Thanx! Gilad

The docs aren't in the easiest to find place, but here's a link to the docs on including MSBuild props/targets files in your package .

Basically, you put the file in the package in the location build\\<tfm>\\<package_id>.props . For example build\\netstandard2.0\\MyPackage.props . If you want your build targets to be included in all TFMs, you can use build\\<package_id>.props , but if your package also contains other assets like lib/ or contentFiles/ , the "no-TFM" build files will cause "asset-target fallback" to fail, so if your package has only net472 libs, and the build files, a project targeting netcoreapp3.0 will get only the build assets, none of the net472 assets. If your build files are in a TFM folder, then NuGet's asset target fallback will select both the lib and build assets. So, I strongly encourage everyone to always use the TFM folder.

The docs need to be improved, but the table explaining lists build , buildTransitive , and buildMultiTargeting . Projects using packages.config only use build assets under build . Projects using PackageReference only use build and buildMultiTargeting assets when the project references the package directly. Assets under buildTransitive get selected when the package is pulled in transitively, rather than directly. The difference between build and buildMultiTargeting is complex. If you understand the concept of "inner-build" and "outer-build" in multi-targeting SDK style projects, that's the difference ( build is inner-build), otherwise only use build .

I should update the docs to have this information.

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