On a Wednesday evening earlier this month, Gary Shapiro dined with executives from a dozen technology companies who are members of his trade association.

The group meeting was routine, but the location for dinner was not. They ate at Mar-a-Lago, a private club in Florida owned by President Trump.

Shapiro, president and CEO of the influential Consumer Technology Association, says he wondered if some would feel "uncomfortable," given the tech industry's opposition to Trump.

"I didn't want to offend anyone," he says.

Shapiro, a Trump critic during the campaign, was one of the first to lay out how the tech industry could work with the new president. Yet, one month into Trump's presidency, that working relationship is increasingly rocky, thanks in large part to the controversial travel ban loathed by Silicon Valley.

Tech leaders are now faced with a difficult balancing act. They worry that appearing to get too close to Trump could damage their standing with customers. But they need to build bridges to the administration on key issues like tax reform and regulations.

The new "calculus" for some companies, according to Shapiro, boils down to: "Are you more concerned about what President Trump can do with a tweet, or are you more concerned with what your customers can do?"

Lately, the answer seems to be the latter.

The CEOs of Uber, Tesla (TSLA) and IBM (IBM) have each had to defend their role on Trump's business advisory council after facing criticism from customers and employees. Uber, in particular, faced a backlash that pushed CEO Travis Kalanick to drop out of the council.

"The Uber issue has sent most companies in the other direction. You get punished for not distancing yourself from this guy," says Bradley Tusk, a regulatory adviser who has worked with Uber and Tesla.

Friending Republicans

The Trump administration can make life difficult for any tech company. It can push for antitrust investigations, scrutinize large mergers, withhold government contracts and slap on new regulations.

During the campaign, Trump said he would create "problems" at Amazon (AMZN) for allegedly being a "monopoly" and not paying enough taxes. He also pledged to block the mega-merger between AT&T (T) and Time Warner (TWX), CNN's parent company.

Some tech companies are now trying to keep a foot in the door with the new D.C. even as they publicly push back against Trump's policies.

"There are lines of communication with the White House. They are still talking," says one lobbyist who works with the tech industry and spoke on the condition of anonymity. But much of the industry's public outreach will likely be directed at federal departments and Congress rather than the president, according to the lobbyist.

Related: Expedia CEO: Hopefully we'll live to see the end of the year

Tech firms are beginning to turn to lobbyists with connections to Trump. The problem is that there aren't many because Trump himself is new to politics.

Brian Ballard, a finance chairman for Trump in Florida, recently opened a new lobbying office in D.C. for federal issues and counts Amazon as a client. The goal, Ballard says, is to help clients figure out the "new universe" in D.C.

"You can't put your head in the sand and say, 'I just wish this didn't happen,'" Ballard tells CNNTech. "It's happened. It's real. And people are adapting to it."

But it's still unclear who exactly tech companies should be courting.

"If you're a company trying to hire Republicans, do you hire Trump Republicans, or [Paul] Ryan Republicans, or [Mike] Pence Republicans, or somebody else?" says one person who works with the big tech companies on government policy.

"I don't think most of us have figured out how to deal with it," the source adds. "From one week to another, it's not clear what's the best tactic."

Silicon Valley gets disrupted

The relationship between tech and Trump has worsened from just two months ago.

Top execs from Apple (AAPL), Amazon (AMZN), Facebook (FB), Alphabet (GOOGL) and other tech companies met with Trump in December.

The conversation touched on key issues for Silicon Valley, including jobs, China, tax reform and immigration. But it was the immigration issue that undermined the working relationship in the first days of Trump's presidency.

After Trump ordered a temporary travel ban on citizens from seven Muslim-majority countries, dozens of tech companies filed court papers arguing it was unconstitutional. For Silicon Valley, the issue was personal.

"It goes directly against all of the values of our ecosystem and our industry," Aaron Levie, CEO and cofounder of Box, told CNNTech after joining the court fight. "The industry got caught off guard."

The result, according to Levie, was a "more stressed relationship" between tech and Trump. "I think that we can have disagreements on specific policies while still being productive and collaborating with the overall administration," Levie says.

But, Levie added, that potential for a productive working relationship "does get reduced with the more unpredictability there is and the more chaos that emerges."

Reps for the White House did not respond to requests for comment.

Related: Mark Zuckerberg's plan to save the world... with Facebook

During the Obama years, the tech industry took positions on political issues like net neutrality and the need for encryption. But Obama was a vocal advocate for tech innovation and has hinted at a desire to be a venture capitalist. The administration basically gave Silicon Valley "a pass," according to one lobbyist.

Some members of Obama's staff came from, or took jobs in, Silicon Valley. So tech companies could push back and still enjoy a strong relationship with the administration.

"Most of our companies have only known a President Obama during their life as a company," says Michael Beckerman, president and CEO of the Internet Association, a trade group that represents Facebook, Snapchat, Pinterest and others. "That's going to be an adjustment."

Trump and his administration may be less willing than Obama to look past the outspokenness on certain issues.

"No one is keeping score, but it is natural to notice who is supportive on key policies," says Charlie Black, a former lobbyist for Trump whose firm Prime Policy Group works with Google.

This may explain why the tech industry chose to speak out in unison against Trump's immigration order. As the source who works with tech companies on government policy put it, "You don't want to be an outlier in a world of Trump."

Advisers and lobbyists are now cautioning tech companies to think twice before opposing the Trump administration.

"It's going to be a long and bumpy four years," Tusk wrote in a memo to his tech clients this month. "Even if you are going to speak out, wait for the right moment."