WASHINGTON (AP) — President Donald Trump cast doubt Friday on whether he would back the massive spending bill needed to avert a government shutdown at midnight, saying he was "considering" a veto. Then, with scant notice, he scheduled a news conference where a White House official said he would indeed sign the legislation.

Telegraphing the conclusion of the made-for-TV drama, an internal White House television feed advertised the event this way: "President Trump Participates in a Bill Signing."

Hours before funding for the government was to expire, and with Congress already on recess, Trump said on Twitter that he was weighing a veto because lawmakers had not fully funded his plans for a border wall with Mexico and had not addressed protection for the 800,000 "Dreamer" immigrants, a program that he has moved to eliminate.

He said in the tweet that young immigrants now protected in the U.S. under Barack Obama's Delayed Action for Childhood Arrivals "have been totally abandoned by the Democrats (not even mentioned in Bill) and the BORDER WALL, which is desperately needed for our National Defense, is not fully funded."

Several advisers inside and outside the White House characterized the tweet as Trump blowing off steam and said they still expected Trump to sign the legislation. An official confirmed that shortly before Trump's appearance, commenting on condition of anonymity because the official was not authorized to speak publicly.

Trump's tweet had been at odds with what top members of Trump's administration and House Speaker Paul Ryan said Thursday, and with a formal statement of administration policy, which said Trump was supportive of the measure.

It came hours after the Senate early Friday morning passed the $1.3 trillion spending package aimed at keeping the government open past midnight. With Congress already out of town, the government will head toward a shutdown if Trump does not sign the bill Friday.

Trump has been increasingly frustrated with the media coverage of the bill, as conservative lawmakers and other critics have railed against it on cable news and in private calls. His tweet was cheered by the conservative House Freedom Caucus, which voted against the spending bill along with two dozen Republicans in the Senate.

Rep. Mark Meadows, R-N.C., chairman of the freedom caucus and a friend of the president, said in a tweet that the group would "fully support" a veto, adding that Congress should pass a short-term budget resolution while Trump and congressional leaders "negotiate a better deal for the forgotten men and women of America."

Sen. Senator Bob Corker, R-Tenn., also egged Trump on. "Please do, Mr. President," he tweeted. "I am just down the street and will bring you a pen. The spending levels without any offsets are grotesque, throwing all of our children under the bus. Totally irresponsible."

"Make my day, Mr. President," taunted Rep. Kurt Schrader, D-Ore.

The Senate passage of the bill averted a third federal shutdown this year, an outcome both parties wanted to avoid. But the budget caps-busting deal drew serious conservative opposition. It also failed to resolve the stalemate over shielding young Dreamer immigrants from deportation after Trump's decision to end the Deferred Action for Childhood Arrivals program last year.

While Trump has repeatedly criticized Democrats over DACA, he canceled the program last fall, ending the issuance of new DACA permits. A judge has forced the administration to continue issuing renewals.

The spending package includes $1.6 billion for Trump's long-promised border wall with Mexico. But less than half of the nearly 95 miles (153 kilometers) of border construction that have been approved can be spent on new barriers. The rest can only be used to repair existing segments.

The money was far less than the $25 billion over 10 years Trump had asked for as part of a last-ditch deal that would have included providing a temporary extension of the DACA program. White House budget officials have nonetheless tried to spin the funding as a win.

"We ended up asking for 74 miles worth of wall, we get 110. Not exactly what we wanted where we wanted," said budget director Mick Mulvaney Thursday. "But generally speaking, we think this is a really, really good immigration package," he said.

Trump, meanwhile, has tried to pin the failure to reach a DACA deal on Democrats, arguing, "They don't want DACA" and are merely trying to use the issue as "a political football."

One Democratic aide said Friday they believed Trump was just trying to get a reaction from Democrats, while another predicted that Trump will ultimately sign the bill. The aides asked not to be named in order to speak frankly.

The House easily approved the spending package Thursday, 256-167, a bipartisan tally that underscored the popularity of the compromise, which funds the government through September. It beefs up military and domestic programs, delivering federal funds to every corner of the country.

But action stalled in the Senate, as conservatives ran the clock in protest. Once the opponents relented, the Senate began voting, clearing the package by a 65-32 vote.

"Shame, shame. A pox on both Houses - and parties," tweeted Sen. Rand Paul, R-Ky., who spent the afternoon tweeting details found in the 2,200-page bill that was released the night before. "No one has read it. Congress is broken."

The omnibus spending bill was supposed to be an antidote to the stopgap measures Congress has been forced to pass — five in this fiscal year alone — to keep government temporarily running amid partisan fiscal disputes.

White House legislative director Marc Short framed it as a compromise. "I can't sit here and tell you and your viewers that we love everything in the bill," he said on Fox. "But we think that we got many of our priorities funded."

But the overall result has been unimaginable to many Republicans after campaigning on spending restraints and balanced budgets. Along with the recent GOP tax cuts law, the bill that stood a foot tall at some lawmakers' desks ushers in the return of $1 trillion deficits.

Trying to smooth over differences, Republican leaders focused on military increases that were once core to the party's brand as guardians of national security.

But even that remained a hard sell — a sign of the entrenched GOP divisions that have made the leadership's job controlling the majority difficult. They will likely repeat in the next budget battle in the fall.