I believe, this is a bug report for Web Application Projects MS Build integration.
I am using Web Application Projects and MS Build. My Website project references another assembly, which has a bunch of culture specific satellite assemblies.
When I build a website using Visual Studio or its "Publish website" feature, the website's bin directory contains all the satellite assemblies in their respective subfolders:
bin\[de]\ReferencedAssembly.resources.dll
bin\[lt]\ReferencedAssembly.resources.dll
bin\[sv]\ReferencedAssembly.resources.dll
... etc.
However, then I build a website using MSBuild, the bin directory of the website (in _PublishedWebsites folder) does not have these satellite assemblies anymore.
While examining Web Application Projects "Microsoft.WebApplication.targets" file, I came to conclusion, that the problem lies in one of "_CopyWebApplication" target's copy tasks:
<!-- copy any referenced assemblies to _PublishedWebsites\app\bin folder -->
<Copy SourceFiles="@(ReferenceCopyLocalPaths)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />
This copy task copies all the satellite assemblies from their language specific subfolders to one single file (!) in the bin folder of website. Which results in loss of all the culture specific assemblies, except for the last one in copy task. I can clearly
see that in build log:
<..skipped copying other referenced assemblies..>
Copying file from "XXX\de\ReferencedAssembly.resources.dll" to "XXX\_PublishedWebsites\Website\bin\ReferencedAssembly.resources.dll".
Copying file from "XXX\lt\ReferencedAssembly.resources.dll" to "XXX\_PublishedWebsites\Website\bin\ReferencedAssembly.resources.dll".
Copying file from "XXX\sv\ReferencedAssembly.resources.dll" to "XXX\_PublishedWebsites\Website\bin\ReferencedAssembly.resources.dll".
<..skipped..>
Is there any way to fix the "_CopyWebApplication" target in "Microsoft.WebApplication.targets" file, so that culture specific assemblies would be copied correctly?
You can fix this problem by modifying "Microsoft.WebApplication.targets" changing the Copy SourceFiles action for IntermediateSatelliteAssembliesWithTargetPath.
I have tried changing the Copy SourceFile action for IntermediateSatelliteAssembliesWithTargetPath, but it did not help. As I've mentioned in my first post, the resource assemblies are not coppied in this action. They are copied in the action a
few lines below:
<!-- copy any referenced assemblies to _PublishedWebsites\app\bin folder -->
<Copy SourceFiles="@(ReferenceCopyLocalPaths)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />
Which is unexpected, but I have verified this behaviour by printing out messages before and after each copy action in "Microsoft.WebApplication.targets".
Maybe this happens, because of our solution configuration (which is pretty basic)? As I wrote in my first post, the website itself does not have culture specific satellite assemblies, but it references another project, which contains all the culture specific
satellite assemblies. However, publishing the site through Visual Studio works fine.
Looking for best practices dealing with publishing Web Application type projects
and dependencies using MSBuild. So far I gather NOT to use the Web Deployment
Projects for this task, as is incompatible with Web Applications that have
nested Web Application in the file structure. I see that the IDE has the
capability to "Publish" a web application to an identified location
and determine what aspects of the Web Application to publish (or not i.e. source
code files). Regretfully the process via the "Publish" wizard is not
save anywhere in the solution. There is a *.Publish.xml which contains the history of the publish, there is additional info on the .user file, but I am still unsure on how to execute the _CopyWebApplication target from the WebApplication target schema, and I was thinking there should be a way to go
through the publish wizard, and instead of executing it would allow you to save
the wizard output to a MSBuild xml type project for automated execution later on
(similar to the way DTS packages use to work in SQL 2000)... I hope there is a
way to do this without resorting to copying the whole folder where the app was
created, and compiled, and then removing the source files etc...
Ok... I figured out that the .Net Web Application Projects by default do not have a <OutDir>C:\DeployPath</OutDir> property, and that the WebApplication default targets include a target called "_CopyWebApplication" regretfully since the .Net WAP Project
lacks this property, if you do not pass it to the msbuild command, it will fail to output the files to the "_PublishedWebsites" folder to be created under "C:\DeployPath" once I figured that out, I was able to compile the .CSProj/.VBProj with msbuild like
so:
None of these seemed to work for me to get referenced assemblies into the _Compiled folder when using
_CopyWebApplication target to copy only the required files to the _Compiled folder of my choice. I resorted to using the Copy task from MSBuild, but considering thet the folder structure of the files I needed to copy did
not allow me to use the built in recursive target, I ended-up having to split the "FROM" and the "TO" folders into manageble chunks. For example in a folder structure like the one below
-wwwroot
-WebApplication
-SQLConnectionCode
-bin/*.dls
-WAP_1
-bin/*.dlls (including reference to SQLConnectionCode dlls and WAP_1Controls dlls below)
-WAP_1Controls
-bin/*.dlls
-WAP_2
-bin/*.dlls (including reference to SQLConnectionCode dlls and WAP_2Controls dlls below)
-WAP_2Controls
-bin/*.dlls
I do not want to copy the folder structure underneath SQLConnectionCode, so If I use a recursive target to copy the web application like so: "C:\InetPub\WWWRoot\WepApplication\**\bin\*.*" to opy files to "C:\InetPub\WWWRoot\WepApplicationDeployment\**\bin\"
the SQLConnectionCode will also be copied. Instead, I had to create separate ItemGroups for each of the WAPs I wanted to. Like so:
and the Copy tasks above, the build gave me exactly the files in the bin folder of all my deployed web applications as if I deployed them by the IDE Publish wizard
None of these seemed to work for me to get referenced assemblies into the _Compiled folder when using
_CopyWebApplication target to copy only the required files to the _Compiled folder of my choice. I resorted to using the Copy task from MSBuild, but considering thet the folder structure of the files I needed to copy did
not allow me to use the built in recursive target, I ended-up having to split the "FROM" and the "TO" folders into manageble chunks. For example in a folder structure like the one below
-wwwroot
-WebApplication
-SQLConnectionCode
-bin/*.dls
-WAP_1
-bin/*.dlls (including reference to SQLConnectionCode dlls and WAP_1Controls dlls below)
-WAP_1Controls
-bin/*.dlls
-WAP_2
-bin/*.dlls (including reference to SQLConnectionCode dlls and WAP_2Controls dlls below)
-WAP_2Controls
-bin/*.dlls
I do not want to copy the folder structure underneath SQLConnectionCode, so If I use a recursive target to copy the web application like so: "C:\InetPub\WWWRoot\WepApplication\**\bin\*.*" to opy files to "C:\InetPub\WWWRoot\WepApplicationDeployment\**\bin\"
the SQLConnectionCode will also be copied. Instead, I had to create separate ItemGroups for each of the WAPs I wanted to. Like so:
Where @(WAPRootDeploy) is a list of the .vpproj/.csproj that make up my deployable solution (minus the referenced projects like th SQLConnection above)
and the Copy tasks above, the build gave me exactly the files in the bin folder of all my deployed web applications as if I deployed them by the IDE Publish wizard
I'm having this same issue still - with VS/TFS 2008 SP1.
The issue with the ReferenceCopyLocalPaths copy (in the _CopyWebApplication target) not supporting cultural resource folders seems to not have been fixed yet. Obviously editing the Microsoft.WebApplication.targets file is not ideal since it may/will be overwritten
in the next version/sp. I wouldn't feel nearly as bad about it if the next version of this file will include the fix.
random user...
Member
15 Points
3 Posts
MSBuild integraction issue when publishing satellite assemblies
Nov 09, 2006 12:13 PM|LINK
Hello,
I believe, this is a bug report for Web Application Projects MS Build integration.
I am using Web Application Projects and MS Build. My Website project references another assembly, which has a bunch of culture specific satellite assemblies.
When I build a website using Visual Studio or its "Publish website" feature, the website's bin directory contains all the satellite assemblies in their respective subfolders:
bin\[de]\ReferencedAssembly.resources.dll
bin\[lt]\ReferencedAssembly.resources.dll
bin\[sv]\ReferencedAssembly.resources.dll
... etc.
However, then I build a website using MSBuild, the bin directory of the website (in _PublishedWebsites folder) does not have these satellite assemblies anymore.
While examining Web Application Projects "Microsoft.WebApplication.targets" file, I came to conclusion, that the problem lies in one of "_CopyWebApplication" target's copy tasks:
<!-- copy any referenced assemblies to _PublishedWebsites\app\bin folder -->
<Copy SourceFiles="@(ReferenceCopyLocalPaths)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />
This copy task copies all the satellite assemblies from their language specific subfolders to one single file (!) in the bin folder of website. Which results in loss of all the culture specific assemblies, except for the last one in copy task. I can clearly see that in build log:
<..skipped copying other referenced assemblies..>
Copying file from "XXX\de\ReferencedAssembly.resources.dll" to "XXX\_PublishedWebsites\Website\bin\ReferencedAssembly.resources.dll".
Copying file from "XXX\lt\ReferencedAssembly.resources.dll" to "XXX\_PublishedWebsites\Website\bin\ReferencedAssembly.resources.dll".
Copying file from "XXX\sv\ReferencedAssembly.resources.dll" to "XXX\_PublishedWebsites\Website\bin\ReferencedAssembly.resources.dll".
<..skipped..>
Is there any way to fix the "_CopyWebApplication" target in "Microsoft.WebApplication.targets" file, so that culture specific assemblies would be copied correctly?
Any other solutions possible?
Thank You,
G.V.
BradleyB
Participant
1197 Points
230 Posts
AspNetTeam
Re: MSBuild integraction issue when publishing satellite assemblies
Nov 16, 2006 05:39 PM|LINK
You can fix this problem by modifying "Microsoft.WebApplication.targets" changing the Copy SourceFiles action for IntermediateSatelliteAssembliesWithTargetPath.
Before:
<Copy SourceFiles="@(IntermediateSatelliteAssembliesWithTargetPath)"
DestinationFolder="$(WebProjectOutputDir)\bin"SkipUnchangedFiles="true" />After:
<Copy SourceFiles="@(IntermediateSatelliteAssembliesWithTargetPath)" DestinationFiles="@(IntermediateSatelliteAssembliesWithTargetPath->'$(WebProjectOutputDir)\bin\%(Culture)\$(TargetName).resources.dll')" SkipUnchangedFiles="true" />
Hope this helps,
Brad.
random user...
Member
15 Points
3 Posts
Re: MSBuild integraction issue when publishing satellite assemblies
Nov 17, 2006 12:43 PM|LINK
Thank you for the response.
I have tried changing the Copy SourceFile action for IntermediateSatelliteAssembliesWithTargetPath, but it did not help. As I've mentioned in my first post, the resource assemblies are not coppied in this action. They are copied in the action a few lines below:
<!-- copy any referenced assemblies to _PublishedWebsites\app\bin folder -->
<Copy SourceFiles="@(ReferenceCopyLocalPaths)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />
Which is unexpected, but I have verified this behaviour by printing out messages before and after each copy action in "Microsoft.WebApplication.targets".
Maybe this happens, because of our solution configuration (which is pretty basic)? As I wrote in my first post, the website itself does not have culture specific satellite assemblies, but it references another project, which contains all the culture specific satellite assemblies. However, publishing the site through Visual Studio works fine.
Any other ideas?
Thank you,
Gundas Vilkelis
BradleyB
Participant
1197 Points
230 Posts
AspNetTeam
Re: MSBuild integraction issue when publishing satellite assemblies
Nov 17, 2006 06:44 PM|LINK
Got it. The change I gave you before was for localized resources in the WAP project. For referenced projects you'll need.
<Copy SourceFiles="@(ReferenceCopyLocalPaths)" DestinationFiles="@(ReferenceCopyLocalPaths->'$(WebProjectOutputDir)\bin\%(DestinationSubDirectory)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
So the "Microsoft.WebApplication.targets" file should have both changes to be correct.
<Copy SourceFiles="@(IntermediateSatelliteAssembliesWithTargetPath)" DestinationFiles="@(IntermediateSatelliteAssembliesWithTargetPath->'$(WebProjectOutputDir)\bin\%(Culture)\$(TargetName).resources.dll')" SkipUnchangedFiles="true" />
<Copy SourceFiles="@(ReferenceCopyLocalPaths)" DestinationFiles="@(ReferenceCopyLocalPaths->'$(WebProjectOutputDir)\bin\%(DestinationSubDirectory)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
Hope this helps, Brad.
random user...
Member
15 Points
3 Posts
Re: MSBuild integraction issue when publishing satellite assemblies
Nov 20, 2006 08:51 AM|LINK
Hi Brad,
These changes have fixed our problem. Thank you!
Regards,
Gundas Vilkelis
jcnovoa
Member
22 Points
10 Posts
Re: MSBuild integraction issue when publishing satellite assemblies
Jan 16, 2007 02:13 PM|LINK
MSBuild Web Application
jcnovoa
Member
22 Points
10 Posts
Re: MSBuild integraction issue when publishing satellite assemblies
Jan 16, 2007 03:37 PM|LINK
Ok... I figured out that the .Net Web Application Projects by default do not have a <OutDir>C:\DeployPath</OutDir> property, and that the WebApplication default targets include a target called "_CopyWebApplication" regretfully since the .Net WAP Project lacks this property, if you do not pass it to the msbuild command, it will fail to output the files to the "_PublishedWebsites" folder to be created under "C:\DeployPath" once I figured that out, I was able to compile the .CSProj/.VBProj with msbuild like so:
msbuild WAP.vbproj /target:_CopyWebApplication /property:OutDir=C:\DeployPath
I think the OutDir should've been part of the WAP projects from the get go, considering thers are web application type projects....
MSBuild Web Application
jcnovoa
Member
22 Points
10 Posts
Re: MSBuild integraction issue when publishing satellite assemblies
Jan 21, 2007 08:02 PM|LINK
None of these seemed to work for me to get referenced assemblies into the _Compiled folder when using _CopyWebApplication target to copy only the required files to the _Compiled folder of my choice. I resorted to using the Copy task from MSBuild, but considering thet the folder structure of the files I needed to copy did not allow me to use the built in recursive target, I ended-up having to split the "FROM" and the "TO" folders into manageble chunks. For example in a folder structure like the one below
-wwwroot
I do not want to copy the folder structure underneath SQLConnectionCode, so If I use a recursive target to copy the web application like so: "C:\InetPub\WWWRoot\WepApplication\**\bin\*.*" to opy files to "C:\InetPub\WWWRoot\WepApplicationDeployment\**\bin\" the SQLConnectionCode will also be copied. Instead, I had to create separate ItemGroups for each of the WAPs I wanted to. Like so:
<
ItemGroup><
WAPReferencesFrom1 Include="C:\Inetpub\wwwroot\WebApplication\WAP1\bin\*.dll;C:\Inetpub\wwwroot\WebApplication\WAP1\bin\*.xml;C:\Inetpub\wwwroot\WebApplication\WAP1\bin\*.pdb" /></
ItemGroup><
ItemGroup><
WAPReferencesFrom2 Include="C:\Inetpub\wwwroot\WebApplication\WAP1\Controls\bin\*.dll;C:\Inetpub\wwwroot\WebApplication\WAP1\Controls\bin\*.xml;C:\Inetpub\wwwroot\WebApplication\WAP1\Controls\bin\*.pdb" /></
ItemGroup><ItemGroup>
<WAPReferencesFrom3 Include="C:\Inetpub\wwwroot\WebApplication\WAP2\bin\*.dll;C:\Inetpub\wwwroot\WebApplication\WAP2\bin\*.xml;C:\Inetpub\wwwroot\WebApplication\WAP2\bin\*.pdb" />
</ItemGroup>
<ItemGroup>
<WAPReferencesFrom4 Include="C:\Inetpub\wwwroot\WebApplication\WAP2\Controls\bin\*.dll;C:\Inetpub\wwwroot\WebApplication\WAP2\Controls\bin\*.xml;C:\Inetpub\wwwroot\WebApplication\WAP2\Controls\bin\*.pdb" />
</ItemGroup>
<ItemGroup>
<WAPReferencesTo1 Include="C:\Inetpub\wwwroot\WebApplication\WAP1\bin" />
</ItemGroup>
<ItemGroup>
<WAPReferencesTo2 Include="C:\Inetpub\wwwroot\WebApplication\WAP1\Controls\bin" />
</ItemGroup>
<ItemGroup>
<WAPReferencesTo3 Include="C:\Inetpub\wwwroot\WebApplication\WAP2\bin" />
</ItemGroup>
<ItemGroup>
<WAPReferencesTo4 Include="C:\Inetpub\wwwroot\WebApplication\WAP2\Controls\bin" />
</ItemGroup>
and then called these ItemGroups from my post-build process:
<
Copy SourceFiles="@(WAPReferencesFrom1)" DestinationFolder="@(WAPReferencesTo1)" /><
Copy SourceFiles="@(WAPReferencesFrom2)" DestinationFolder="@(WAPReferencesTo2)" /><
Copy SourceFiles="@(WAPReferencesFrom3)" DestinationFolder="@(WAPReferencesTo3)" /><Copy SourceFiles="@(eHubReferencesFrom4)" DestinationFolder="@(eHubReferencesTo4)" />
<
Copy SourceFiles="@(eHubReferencesFrom5)" DestinationFolder="@(eHubReferencesTo5)" /><
Copy SourceFiles="@(eHubReferencesFrom6)" DestinationFolder="@(eHubReferencesTo6)" /><
Copy SourceFiles="@(eHubReferencesFrom7)" DestinationFolder="@(eHubReferencesTo7)" /><
Copy SourceFiles="@(eHubReferencesFrom8)" DestinationFolder="@(eHubReferencesTo8)" /><
Copy SourceFiles="@(eHubReferencesFrom9)" DestinationFolder="@(eHubReferencesTo9)" />By using
<
MSBuild Properties="OutDir=C:\Inetpub\wwwroot\WAPCompiled\" Targets="_CopyWebApplication" Projects="@(WAPRootDeploy)" StopOnFirstFailure="true">and the Copy tasks above, the build gave me exactly the files in the bin folder of all my deployed web applications as if I deployed them by the IDE Publish wizard
MSBuild Web Application
jcnovoa
Member
22 Points
10 Posts
Re: MSBuild integraction issue when publishing satellite assemblies
Jan 21, 2007 08:06 PM|LINK
None of these seemed to work for me to get referenced assemblies into the _Compiled folder when using _CopyWebApplication target to copy only the required files to the _Compiled folder of my choice. I resorted to using the Copy task from MSBuild, but considering thet the folder structure of the files I needed to copy did not allow me to use the built in recursive target, I ended-up having to split the "FROM" and the "TO" folders into manageble chunks. For example in a folder structure like the one below
-wwwroot
I do not want to copy the folder structure underneath SQLConnectionCode, so If I use a recursive target to copy the web application like so: "C:\InetPub\WWWRoot\WepApplication\**\bin\*.*" to opy files to "C:\InetPub\WWWRoot\WepApplicationDeployment\**\bin\" the SQLConnectionCode will also be copied. Instead, I had to create separate ItemGroups for each of the WAPs I wanted to. Like so:
<
ItemGroup><
WAPReferencesFrom1 Include="C:\Inetpub\wwwroot\WebApplication\WAP1\bin\*.dll;C:\Inetpub\wwwroot\WebApplication\WAP1\bin\*.xml;C:\Inetpub\wwwroot\WebApplication\WAP1\bin\*.pdb" /></
ItemGroup><
ItemGroup><
WAPReferencesFrom2 Include="C:\Inetpub\wwwroot\WebApplication\WAP1\Controls\bin\*.dll;C:\Inetpub\wwwroot\WebApplication\WAP1\Controls\bin\*.xml;C:\Inetpub\wwwroot\WebApplication\WAP1\Controls\bin\*.pdb" /></
ItemGroup><ItemGroup>
<WAPReferencesFrom3 Include="C:\Inetpub\wwwroot\WebApplication\WAP2\bin\*.dll;C:\Inetpub\wwwroot\WebApplication\WAP2\bin\*.xml;C:\Inetpub\wwwroot\WebApplication\WAP2\bin\*.pdb" />
</ItemGroup>
<ItemGroup>
<WAPReferencesFrom4 Include="C:\Inetpub\wwwroot\WebApplication\WAP2\Controls\bin\*.dll;C:\Inetpub\wwwroot\WebApplication\WAP2\Controls\bin\*.xml;C:\Inetpub\wwwroot\WebApplication\WAP2\Controls\bin\*.pdb" />
</ItemGroup>
<ItemGroup>
<WAPReferencesTo1 Include="C:\Inetpub\wwwroot\WebApplication\WAP1\bin" />
</ItemGroup>
<ItemGroup>
<WAPReferencesTo2 Include="C:\Inetpub\wwwroot\WebApplication\WAP1\Controls\bin" />
</ItemGroup>
<ItemGroup>
<WAPReferencesTo3 Include="C:\Inetpub\wwwroot\WebApplication\WAP2\bin" />
</ItemGroup>
<ItemGroup>
<WAPReferencesTo4 Include="C:\Inetpub\wwwroot\WebApplication\WAP2\Controls\bin" />
</ItemGroup>
and then called these ItemGroups from my post-build process:
<
Copy SourceFiles="@(WAPReferencesFrom1)" DestinationFolder="@(WAPReferencesTo1)" /><
Copy SourceFiles="@(WAPReferencesFrom2)" DestinationFolder="@(WAPReferencesTo2)" /><
Copy SourceFiles="@(WAPReferencesFrom3)" DestinationFolder="@(WAPReferencesTo3)" /><Copy SourceFiles="@(WAPReferencesFrom4)" DestinationFolder="@(WAPReferencesTo4)" />
By using<
MSBuild Properties="OutDir=C:\Inetpub\wwwroot\WAPCompiled\" Targets="_CopyWebApplication" Projects="@(WAPRootDeploy)" StopOnFirstFailure="true">Where @(WAPRootDeploy) is a list of the .vpproj/.csproj that make up my deployable solution (minus the referenced projects like th SQLConnection above)
and the Copy tasks above, the build gave me exactly the files in the bin folder of all my deployed web applications as if I deployed them by the IDE Publish wizard
MSBuild Web Application
mpw
Member
2 Points
1 Post
Re: MSBuild integraction issue when publishing satellite assemblies
Jul 28, 2009 06:58 PM|LINK
I'm having this same issue still - with VS/TFS 2008 SP1.
The issue with the ReferenceCopyLocalPaths copy (in the _CopyWebApplication target) not supporting cultural resource folders seems to not have been fixed yet. Obviously editing the Microsoft.WebApplication.targets file is not ideal since it may/will be overwritten in the next version/sp. I wouldn't feel nearly as bad about it if the next version of this file will include the fix.
When will this fix be put into production?