简体   繁体   中英

Using wildcards in csproj to include whole folders in SharePoint wsp package

I just spend the last 4 or so hours trying to figure why when compiling a SharePoint deployed package (wsp file) files that were specified via wildcards were not always getting included in the package. The "always" turned out to be "never on a clean build" and "usually, otherwise". In actual fact the files pointed to by the wildcard specification didn't exist at the point the project loaded (they are put there are part of the build) and this turned out to be the crux of the problem - it seems that the wildcard expansion only occurs when Visual Studio or MSBuild (it happens in both) loads up the csproj file. If there are no files present at that point, then any files placed there as part of the build will be considered for file package inclusion.

In the end I was able to partially solve the issue by having the required files placed there by the building of a secondary project (which the primary project depends on), but even this doesn't work properly in VS the first time you ever load the solution. Essentially you have to build the solution once, then close and re-open then build again for all the files to be included. MSBuild seems to work differently and only expand the wildcards when it first starts to build the specific project.

I guess what I'd like to know is if there's a better way of doing this - eg is it possible to use wildcard inclusion in .spdata files, or is there some other way to specify entire directories to be included into .wsp files (with the ability to specify the destination directory name)?

If i understood you correctly, your problems come from the evaluation of the Files Items in the msbuild.

if u specify a inside the packaging target a new itemgroup it will only be evaluated once stepped into the target, for example:

    <Target Name="ConfigurationChanges" AfterTargets="Build">
        <ItemGroup>
            <ConfigFiles Include="$(DeliveryFolder)\**\*.spdata"/>
        </ItemGroup>
    </Target>

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