Yes, he did.
“He has already made the American economy strong again,” Mr Modi said. “He has achieved much for the US and the world. Friends, we in India have connected well with President Trump.” With a smile, he added: “In the words of candidate Trump: Abki baar Trump sarkar (This time, [a] Trump government).” (Backlash against Modi as Indian PM 'endorses Trump for 2020 in breach of diplomatic convention')
As is evident from the praise lavished on Trump and the use of Trump's election ad slogan, it is hard to interpret this as anything other than an endorsement of Trump during a US election year.
As the article points out,
This wasn’t a foreign policy focused event or one dominated by the Indian-American relationship. While both leaders nodded to the connections between the two countries, the bulk of their speeches was focused on their own individual achievements and their electoral popularity.
Unless one is ready to accept the claim that Narendra Modi is stupid about politics, anyone political savvy can clearly see that Modi had been invited by Trump to a rally of Indian-American diaspora to win their support for Trump's election. Moreover, the use of Trump's election ad slogan by Modi - Ab ki baar, Trump Sarkar - would ofcourse obviously be interpreted as an endorsement of Trump by Narendra Modi during a US election year!
The BBC also points this out:
This rally has been called a win-win for both the leaders. For President Trump, it was a chance to court Indian-Americans for the 2020 presidential election race where Texas could emerge as a battleground state. For Mr Modi, a PR triumph and picture with the president of the United States may help him shrug off the criticism over his recent strong-arm polices at home.
... The US has a population of about 4 million Indians who are seen as an increasingly important vote bank in the country. The 2010 US census shows that Texas is home to the fourth-largest Indian-American population in the country after California, New York and New Jersey. Analysis of voting patterns shows the community tends overwhelmingly to support the Democrat party.
To add to this, Trump later released political ads with Modi featuring in them - PM Modi features in US elections! Trump campaign releases commercial to woo Indian-American voters - making it very clear that Modi was indeed an important part of his election campaign.
Did Modi violate the principles of Indian foreign policy?
Yes, he did.
What does Indian foreign policy says about this?
"But, there is a time-honoured convention of India's foreign policy that when we engage with the foreign governments or the President or Prime Minister when on foreign soil, we do not take part in the domestic electoral politics. Prime Minister should have honoured that," Sharma told reporters. (Modi violated India's foreign policy principles by 'campaigning' for Trump: Congress).
What instances there have been in the past of a foreign Prime Minister or President being invited as a star campaigner in the US election campaign?
None. No indian PM, before Modi, has campaigned for any US candidate in any US elections.