Open JensSchadron opened 11 months ago
@JensSchadron the apk/aab is built as part of the dotnet build
step. All publish does is copy the outputs to the publish directory. This is by design. So in order to get the results you want you should set the appropriate signing keys for the dotnet build
call.
@dellis1972 Just to make sure I understand correctly, I can remove all the property arguments from the publish step, straight to the build step and get the same result? Or should they be added to both build and publish commands?
They are only required on the build
step I think. That said I'm not sure if our property Cache will cause a build if they are not provided in the publish. But based on the fast the _Sign
target is skipped when do you provide them it should work that way.
The reason for all this is the publsh
command is not called as part of the Debug loop in VS. As a result if we don't produce the apk in the build
step there would be nothing to debug. So the publish
command really is just a copy apk to output
step.
@jonathanpeppers what I've said is right isn't it? my memory is a bit fuzzy on some of the changes we did for .net 6.
I see, thanks for clarifying. I'll experiment a little bit more with it then. Will also close the issue as soon as Jonathan peppers has confirmed it then. 🙂
I think that it might also be worthwhile to mention this behavior in the docs
Yes dotnet publish
doesn't do much:
It basically adds the right files to @(ResolvedFileToPublish)
so they are copied to $(PublishDir)
. You can just use dotnet build
if you like on Android, and never use dotnet publish
.
Is the underlying problem actually:
Can you verify if you see the same thing with dotnet build
? That probably points to this issue, if so.
Not sure if it could be called an incremental build if there's only a change in the keystore settings, but yes it basically boils down to that.
Yes, I think it really is an issue then -- incremental build is basically any build where bin
and obj
had files leftover IMO.
Android application type
.NET Android (net7.0-android, etc.)
Affected platform version
.NET 8 RC2 / .NET 7, MacOS Ventura 13.5.2
Description
I noticed that when using
dotnet publish
after having issued thedotnet build
command, will ignore the provided keystore information in thedotnet publish
command, which seemed kinda counterintuitive. Reason why I'm usingdotnet build
first is to ensure that everything actually compiles, then subsequently run all unit tests, and if all those are successful, we create the actual signed apk.However... when doing so while having more verbose logs, I get informed that the
_sign
build target was a no-op. See screenshot below.Steps to Reproduce
dotnet restore
dotnet build source/SigningIssueReproApp/SigningIssueReproApp.csproj --configuration Release --no-restore
(generated apk gets signed by a debug.keystore)dotnet publish source/SigningIssueReproApp/SigningIssueReproApp.csproj --configuration Release --no-restore --output artifacts/ /property:AndroidKeyStore=True /property:AndroidSigningKeyStore=/Users/jens/Documents/Projects/SigningIssueReproApp/deploy/myapp.keystore /property:AndroidSigningKeyAlias=myapp /property:AndroidSigningKeyPass=password /property:AndroidSigningStorePass=password
(make sure to adjust the path to the keystore as the CLI apparently somehow requires an absolute path to that file)Did you find any workaround?
A workaround that was provided to me by a colleague, which isn't exactly clean to me, is to also provide all the keystore information to
dotnet build
. I'm currently not aware about any other possible workarounds that work.Relevant log output