MSBuild ignores GatherAllFilesToPublish?
So, I created a publish profile for my web app. I did this with the GUI in VS 2017 Enterprise. I then found an example of how to change the pubxml to make it zip all the output files. Eventually I ended up with this:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<PrecompileBeforePublish>True</PrecompileBeforePublish>
<EnableUpdateable>True</EnableUpdateable>
<DebugSymbols>False</DebugSymbols>
<WDPMergeOption>DonotMerge</WDPMergeOption>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>binReleasePublish</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<Configuration>Release</Configuration>
</PropertyGroup>
<Target Name="ZipPublishOutput" AfterTargets="GatherAllFilesToPublish">
<Exec Command='powershell -nologo -noprofile -command "compress-archive -force -path $(WPPAllFilesInSingleFolder)* -destinationpath $(publishUrl).zip"' />
</Target>
</Project>
This works perfectly fine if I do a publish through Visual Studio. However, I've been trying everything I can think of to get this to work in MSBuild, with no luck.
Here is an example of what I think should work:
"C:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuild15.0BinMSBuild.exe" WebApp.csproj /nologo /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=ReleasePublish
And for reference, here is the version of MSBuild:
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Framework
I know MSBuild is finding the profile pubxml because I can make a change to the settings, such as publishUrl, and those changes are applied the next time I run MSBuild. What doesn't seem to work is the ZipPublishOutput target. And even running MSBuild with diagnostic verbosity shows that GatherAllFilesToPublish never runs, which would mean my target wouldn't run.
I've found many different suggestions and nothing seems to help. A lot of the solutions I found seemed to be with MSBuild not finding the pubxml, but that's not the case here.
So, is GatherAllFilesToPublish something that is Visual Studio specific, and therefore MSBuild doesn't know about it? That seems like how it's acting.
msbuild
add a comment |
So, I created a publish profile for my web app. I did this with the GUI in VS 2017 Enterprise. I then found an example of how to change the pubxml to make it zip all the output files. Eventually I ended up with this:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<PrecompileBeforePublish>True</PrecompileBeforePublish>
<EnableUpdateable>True</EnableUpdateable>
<DebugSymbols>False</DebugSymbols>
<WDPMergeOption>DonotMerge</WDPMergeOption>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>binReleasePublish</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<Configuration>Release</Configuration>
</PropertyGroup>
<Target Name="ZipPublishOutput" AfterTargets="GatherAllFilesToPublish">
<Exec Command='powershell -nologo -noprofile -command "compress-archive -force -path $(WPPAllFilesInSingleFolder)* -destinationpath $(publishUrl).zip"' />
</Target>
</Project>
This works perfectly fine if I do a publish through Visual Studio. However, I've been trying everything I can think of to get this to work in MSBuild, with no luck.
Here is an example of what I think should work:
"C:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuild15.0BinMSBuild.exe" WebApp.csproj /nologo /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=ReleasePublish
And for reference, here is the version of MSBuild:
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Framework
I know MSBuild is finding the profile pubxml because I can make a change to the settings, such as publishUrl, and those changes are applied the next time I run MSBuild. What doesn't seem to work is the ZipPublishOutput target. And even running MSBuild with diagnostic verbosity shows that GatherAllFilesToPublish never runs, which would mean my target wouldn't run.
I've found many different suggestions and nothing seems to help. A lot of the solutions I found seemed to be with MSBuild not finding the pubxml, but that's not the case here.
So, is GatherAllFilesToPublish something that is Visual Studio specific, and therefore MSBuild doesn't know about it? That seems like how it's acting.
msbuild
add a comment |
So, I created a publish profile for my web app. I did this with the GUI in VS 2017 Enterprise. I then found an example of how to change the pubxml to make it zip all the output files. Eventually I ended up with this:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<PrecompileBeforePublish>True</PrecompileBeforePublish>
<EnableUpdateable>True</EnableUpdateable>
<DebugSymbols>False</DebugSymbols>
<WDPMergeOption>DonotMerge</WDPMergeOption>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>binReleasePublish</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<Configuration>Release</Configuration>
</PropertyGroup>
<Target Name="ZipPublishOutput" AfterTargets="GatherAllFilesToPublish">
<Exec Command='powershell -nologo -noprofile -command "compress-archive -force -path $(WPPAllFilesInSingleFolder)* -destinationpath $(publishUrl).zip"' />
</Target>
</Project>
This works perfectly fine if I do a publish through Visual Studio. However, I've been trying everything I can think of to get this to work in MSBuild, with no luck.
Here is an example of what I think should work:
"C:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuild15.0BinMSBuild.exe" WebApp.csproj /nologo /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=ReleasePublish
And for reference, here is the version of MSBuild:
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Framework
I know MSBuild is finding the profile pubxml because I can make a change to the settings, such as publishUrl, and those changes are applied the next time I run MSBuild. What doesn't seem to work is the ZipPublishOutput target. And even running MSBuild with diagnostic verbosity shows that GatherAllFilesToPublish never runs, which would mean my target wouldn't run.
I've found many different suggestions and nothing seems to help. A lot of the solutions I found seemed to be with MSBuild not finding the pubxml, but that's not the case here.
So, is GatherAllFilesToPublish something that is Visual Studio specific, and therefore MSBuild doesn't know about it? That seems like how it's acting.
msbuild
So, I created a publish profile for my web app. I did this with the GUI in VS 2017 Enterprise. I then found an example of how to change the pubxml to make it zip all the output files. Eventually I ended up with this:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<PrecompileBeforePublish>True</PrecompileBeforePublish>
<EnableUpdateable>True</EnableUpdateable>
<DebugSymbols>False</DebugSymbols>
<WDPMergeOption>DonotMerge</WDPMergeOption>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>binReleasePublish</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<Configuration>Release</Configuration>
</PropertyGroup>
<Target Name="ZipPublishOutput" AfterTargets="GatherAllFilesToPublish">
<Exec Command='powershell -nologo -noprofile -command "compress-archive -force -path $(WPPAllFilesInSingleFolder)* -destinationpath $(publishUrl).zip"' />
</Target>
</Project>
This works perfectly fine if I do a publish through Visual Studio. However, I've been trying everything I can think of to get this to work in MSBuild, with no luck.
Here is an example of what I think should work:
"C:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuild15.0BinMSBuild.exe" WebApp.csproj /nologo /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=ReleasePublish
And for reference, here is the version of MSBuild:
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Framework
I know MSBuild is finding the profile pubxml because I can make a change to the settings, such as publishUrl, and those changes are applied the next time I run MSBuild. What doesn't seem to work is the ZipPublishOutput target. And even running MSBuild with diagnostic verbosity shows that GatherAllFilesToPublish never runs, which would mean my target wouldn't run.
I've found many different suggestions and nothing seems to help. A lot of the solutions I found seemed to be with MSBuild not finding the pubxml, but that's not the case here.
So, is GatherAllFilesToPublish something that is Visual Studio specific, and therefore MSBuild doesn't know about it? That seems like how it's acting.
msbuild
msbuild
asked Nov 22 '18 at 2:38
DanDan
161415
161415
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Just got the same problem using msbuild with Jenkins.
To execute the target GatherAllFilesToPublish with msbuild I had to add the target /t:GatherAllFilesToPublish in the msbuild command line.
You should have something like this :
/p:DeployOnBuild=true /p:PublishProfile=fullPathToMyPubXML.pubxml
/t:GatherAllFilesToPublish
That does seem to work. I guess I was expecting it to be implied as part of the publish profile, but I guess that's not how it works. Thanks.
– Dan
Nov 29 '18 at 7:01
It should work by default, but it seems that MsBuild and Visual Studio don't use the same rules, or simply it's just broken in MsBuild. So we have to rely on cheap trick to make it work unfortunately. I guess it's related to the target GatherAllFilesToPublish being defined in Microsoft.WebApplication.targets.
– C. Cuvillier
Nov 30 '18 at 9:16
Well, I guess I spoke too soon. The zip file that I get from running that publish profile through VS is about 10 megs larger and works, whereas this one generates something that doesn't work.
– Dan
Dec 2 '18 at 17:30
By default, MSBuild use the debug configuration to publish. Use the release configuration by adding : /p:Configuration=Release
– C. Cuvillier
Dec 7 '18 at 13:17
I was. This is what I ran: "C:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuild15.0BinMSBuild.exe" WebApp.csproj /nologo /verbosity:minimal /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=ReleasePublish /t:GatherAllFilesToPublish
– Dan
Dec 7 '18 at 18:29
|
show 2 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53423119%2fmsbuild-ignores-gatherallfilestopublish%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Just got the same problem using msbuild with Jenkins.
To execute the target GatherAllFilesToPublish with msbuild I had to add the target /t:GatherAllFilesToPublish in the msbuild command line.
You should have something like this :
/p:DeployOnBuild=true /p:PublishProfile=fullPathToMyPubXML.pubxml
/t:GatherAllFilesToPublish
That does seem to work. I guess I was expecting it to be implied as part of the publish profile, but I guess that's not how it works. Thanks.
– Dan
Nov 29 '18 at 7:01
It should work by default, but it seems that MsBuild and Visual Studio don't use the same rules, or simply it's just broken in MsBuild. So we have to rely on cheap trick to make it work unfortunately. I guess it's related to the target GatherAllFilesToPublish being defined in Microsoft.WebApplication.targets.
– C. Cuvillier
Nov 30 '18 at 9:16
Well, I guess I spoke too soon. The zip file that I get from running that publish profile through VS is about 10 megs larger and works, whereas this one generates something that doesn't work.
– Dan
Dec 2 '18 at 17:30
By default, MSBuild use the debug configuration to publish. Use the release configuration by adding : /p:Configuration=Release
– C. Cuvillier
Dec 7 '18 at 13:17
I was. This is what I ran: "C:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuild15.0BinMSBuild.exe" WebApp.csproj /nologo /verbosity:minimal /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=ReleasePublish /t:GatherAllFilesToPublish
– Dan
Dec 7 '18 at 18:29
|
show 2 more comments
Just got the same problem using msbuild with Jenkins.
To execute the target GatherAllFilesToPublish with msbuild I had to add the target /t:GatherAllFilesToPublish in the msbuild command line.
You should have something like this :
/p:DeployOnBuild=true /p:PublishProfile=fullPathToMyPubXML.pubxml
/t:GatherAllFilesToPublish
That does seem to work. I guess I was expecting it to be implied as part of the publish profile, but I guess that's not how it works. Thanks.
– Dan
Nov 29 '18 at 7:01
It should work by default, but it seems that MsBuild and Visual Studio don't use the same rules, or simply it's just broken in MsBuild. So we have to rely on cheap trick to make it work unfortunately. I guess it's related to the target GatherAllFilesToPublish being defined in Microsoft.WebApplication.targets.
– C. Cuvillier
Nov 30 '18 at 9:16
Well, I guess I spoke too soon. The zip file that I get from running that publish profile through VS is about 10 megs larger and works, whereas this one generates something that doesn't work.
– Dan
Dec 2 '18 at 17:30
By default, MSBuild use the debug configuration to publish. Use the release configuration by adding : /p:Configuration=Release
– C. Cuvillier
Dec 7 '18 at 13:17
I was. This is what I ran: "C:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuild15.0BinMSBuild.exe" WebApp.csproj /nologo /verbosity:minimal /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=ReleasePublish /t:GatherAllFilesToPublish
– Dan
Dec 7 '18 at 18:29
|
show 2 more comments
Just got the same problem using msbuild with Jenkins.
To execute the target GatherAllFilesToPublish with msbuild I had to add the target /t:GatherAllFilesToPublish in the msbuild command line.
You should have something like this :
/p:DeployOnBuild=true /p:PublishProfile=fullPathToMyPubXML.pubxml
/t:GatherAllFilesToPublish
Just got the same problem using msbuild with Jenkins.
To execute the target GatherAllFilesToPublish with msbuild I had to add the target /t:GatherAllFilesToPublish in the msbuild command line.
You should have something like this :
/p:DeployOnBuild=true /p:PublishProfile=fullPathToMyPubXML.pubxml
/t:GatherAllFilesToPublish
answered Nov 28 '18 at 14:30
C. CuvillierC. Cuvillier
16
16
That does seem to work. I guess I was expecting it to be implied as part of the publish profile, but I guess that's not how it works. Thanks.
– Dan
Nov 29 '18 at 7:01
It should work by default, but it seems that MsBuild and Visual Studio don't use the same rules, or simply it's just broken in MsBuild. So we have to rely on cheap trick to make it work unfortunately. I guess it's related to the target GatherAllFilesToPublish being defined in Microsoft.WebApplication.targets.
– C. Cuvillier
Nov 30 '18 at 9:16
Well, I guess I spoke too soon. The zip file that I get from running that publish profile through VS is about 10 megs larger and works, whereas this one generates something that doesn't work.
– Dan
Dec 2 '18 at 17:30
By default, MSBuild use the debug configuration to publish. Use the release configuration by adding : /p:Configuration=Release
– C. Cuvillier
Dec 7 '18 at 13:17
I was. This is what I ran: "C:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuild15.0BinMSBuild.exe" WebApp.csproj /nologo /verbosity:minimal /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=ReleasePublish /t:GatherAllFilesToPublish
– Dan
Dec 7 '18 at 18:29
|
show 2 more comments
That does seem to work. I guess I was expecting it to be implied as part of the publish profile, but I guess that's not how it works. Thanks.
– Dan
Nov 29 '18 at 7:01
It should work by default, but it seems that MsBuild and Visual Studio don't use the same rules, or simply it's just broken in MsBuild. So we have to rely on cheap trick to make it work unfortunately. I guess it's related to the target GatherAllFilesToPublish being defined in Microsoft.WebApplication.targets.
– C. Cuvillier
Nov 30 '18 at 9:16
Well, I guess I spoke too soon. The zip file that I get from running that publish profile through VS is about 10 megs larger and works, whereas this one generates something that doesn't work.
– Dan
Dec 2 '18 at 17:30
By default, MSBuild use the debug configuration to publish. Use the release configuration by adding : /p:Configuration=Release
– C. Cuvillier
Dec 7 '18 at 13:17
I was. This is what I ran: "C:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuild15.0BinMSBuild.exe" WebApp.csproj /nologo /verbosity:minimal /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=ReleasePublish /t:GatherAllFilesToPublish
– Dan
Dec 7 '18 at 18:29
That does seem to work. I guess I was expecting it to be implied as part of the publish profile, but I guess that's not how it works. Thanks.
– Dan
Nov 29 '18 at 7:01
That does seem to work. I guess I was expecting it to be implied as part of the publish profile, but I guess that's not how it works. Thanks.
– Dan
Nov 29 '18 at 7:01
It should work by default, but it seems that MsBuild and Visual Studio don't use the same rules, or simply it's just broken in MsBuild. So we have to rely on cheap trick to make it work unfortunately. I guess it's related to the target GatherAllFilesToPublish being defined in Microsoft.WebApplication.targets.
– C. Cuvillier
Nov 30 '18 at 9:16
It should work by default, but it seems that MsBuild and Visual Studio don't use the same rules, or simply it's just broken in MsBuild. So we have to rely on cheap trick to make it work unfortunately. I guess it's related to the target GatherAllFilesToPublish being defined in Microsoft.WebApplication.targets.
– C. Cuvillier
Nov 30 '18 at 9:16
Well, I guess I spoke too soon. The zip file that I get from running that publish profile through VS is about 10 megs larger and works, whereas this one generates something that doesn't work.
– Dan
Dec 2 '18 at 17:30
Well, I guess I spoke too soon. The zip file that I get from running that publish profile through VS is about 10 megs larger and works, whereas this one generates something that doesn't work.
– Dan
Dec 2 '18 at 17:30
By default, MSBuild use the debug configuration to publish. Use the release configuration by adding : /p:Configuration=Release
– C. Cuvillier
Dec 7 '18 at 13:17
By default, MSBuild use the debug configuration to publish. Use the release configuration by adding : /p:Configuration=Release
– C. Cuvillier
Dec 7 '18 at 13:17
I was. This is what I ran: "C:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuild15.0BinMSBuild.exe" WebApp.csproj /nologo /verbosity:minimal /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=ReleasePublish /t:GatherAllFilesToPublish
– Dan
Dec 7 '18 at 18:29
I was. This is what I ran: "C:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuild15.0BinMSBuild.exe" WebApp.csproj /nologo /verbosity:minimal /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=ReleasePublish /t:GatherAllFilesToPublish
– Dan
Dec 7 '18 at 18:29
|
show 2 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53423119%2fmsbuild-ignores-gatherallfilestopublish%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown